如何使用可以采用任何对象数组的方法声明对象?
在代码中:(1)代码有一个编译错误“数组中的类型不兼容”。(2) 没有错误。我想使用(1)。
declare var enyo;
// (1). compile error: 'Incompatible types in array'
enyo.kind({
name: "HelloWidget",
components: [
{ name: "hello", content: "Hello From Enyo" },
{ kind: "Button", content: "Click Me!", ontap: "helloTap" }
]
});
// (2). no erros but have to write <any>
enyo.kind({
name: "HelloWidget",
components: [
<any>{ name: "hello", content: "Hello From Enyo" },
<any>{ kind: "Button", content: "Click Me!", ontap: "helloTap" }
]
});