typescript - 如何在 Typescript 中编写 Polymer3 Mixin
问题描述
如果我尝试在 Typescript 中编写具有自己属性的 polymer3 mixin,它将失败并出现以下错误:
xxx 错误地扩展了 yyy
属性类型不兼容
我已经这样做了(但在 Typescript 中)有没有办法在没有 ts-ignore 的情况下解决?
示例代码:
function VisuElement<B extends Constructor<any>>(base: B) {
return class extends base {
constructor(...args: any[]) {
super();
this._ve = true;
this._veBindings = [];
}
static get properties() {
return {
unbindOnUnload: Boolean //Needed when a Element is created via a Dom repeat
}
}
}
}
用法:
class VisuSignalValueDisplay extends VisuElement(PolymerElement) {
static get template() {
return html`
<div></div>
`;
}
static get is() { return 'visu-signal-value-display'; }
static get properties() {
return {
signalName: String
};
}
}
解决方案
推荐阅读
- php - 从我的 Magento 1.9 src 文件夹中删除 Install.php 是否安全?
- bootstrap-4 - Bootstrap 导出仅显示 CSV 选项
- android - Python EXIF 提取导致 Android 照片出错
- javascript - 如何在 select2 上调用 onclick 事件
- javascript - React/enzyme - How to test reference function
- java - Converting date object to yyyy-MM-dd hh:mm:ss
- jquery - Working with Jquery appended elements in MVC
- regex - 使用混合的单行和多行内容解析日志
- angular - 黄瓜 - 量角器不识别步骤定义
- xamarin.forms - Print dynamic images along with text