当子类化List-Element Class以添加进一步的类型时,应该重写@property
修饰符还是只重写类型和初始值设定项?换句话说,假设我有这样的代码:
interface AB {
a: number,
b: string,
}
@customElement('my-parent')
class MyParent extends LitElement {
@property({type: Array}) stuff: readonly any[] = [];
}
作为子类化的一种方式,以下哪一项是正确的:
@customElement('my-child')
class MyChild extends MyParent {
override @property({type: Array}) stuff: readonly Readonly<AB>[] = [];
}
或
@customElement('my-child')
class MyChild extends MyParent {
override stuff: readonly Readonly<AB>[] = [];
}
Both seem to be w或king in my codebase, so I'm not sure which to standardize to.