【发布时间】:2014-10-13 03:16:17
【问题描述】:
我正在为一个对象创建一个接口,该对象具有用于将键映射到字符串值的字符串。这似乎是一件相当简单的事情,但我一直无法
错误显示here
我已签出 Is it possible to define an object containing objects? 和 Enforcing the type of the indexed members of a Typescript object? 但我无法正确访问这些值。
这是代码
interface ISomeQuestions {
[key:string] : string;
}
var x:ISomeQuestions = {
"question1": "",
"question2": "",
"a": ""
};
console.log(x.question1);
最后一行反映了我想要完成的事情
【问题讨论】:
标签: typescript