[英]interface definition in typescript
interface Entry {
fn: Function,
id?: number,
recur?: number
}
interface Schedule {
[tick: number]: Entry[]
}
Defination of interface in typescript is not the same as in java. typescript中接口的定义与java中的定义不同。 I can't understand this line:
[tick: number]: Entry[]
. 我无法理解这一行:
[tick: number]: Entry[]
。 Can you tell me what's it mean? 你能告诉我这是什么意思吗?
that definition seems to be an indexer property that can be used as: 该定义似乎是一个索引器属性,可用作:
let a: Schedule = {};
a[5] = anEntryArray; // succeeds
a["5"] = anEntryArray; // fails
a[5] = "a string"; // fails
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.