【发布时间】:2017-04-10 00:25:02
【问题描述】:
我有一个这样的代码 sn-p:
export class TagCloud {
tags: [Tag];
locations: [Location];
constructor() {
this.tags = new Array<Tag>();
this.locations = new Array<Location>();
}
}
但这给了我以下错误:
错误 TS2322:类型“Tag[]”不可分配给类型“[Tag]”。 “Tag[]”类型中缺少属性“0”。
错误 TS2322:类型 'Location[]' 不可分配给类型 '[Lo 阳离子]'。 “Location[]”类型中缺少属性“0”。
我做错了什么(代码可以运行)?
我正在使用带有 es6-shim 类型描述 (https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/es6-shim) 的类型。
【问题讨论】:
标签: typescript ecmascript-6 typescript-typings definitelytyped