在VS2013中,当tsc以代码1退出时,构建停止.在VS2012中不是这种情况.
如何在忽略tsc.exe错误的同时运行我的解决方案?
我收到很多The property 'x' does not exist on value of type 'y'错误,我想在使用javascript函数时忽略这些错误.
我不明白为什么这段代码会生成TypeScript错误.(这不是原始代码,有点派生,所以请忽略示例中的无意义):
interface Images {
[key:string]: string;
}
function getMainImageUrl(images: Images): string {
return images.main;
}
Run Code Online (Sandbox Code Playgroud)
我收到错误(使用TypeScript 1.7.5):
错误TS2339:"图像"类型中不存在属性"main".
当然,写作时我可以摆脱错误:
return images["main"];
Run Code Online (Sandbox Code Playgroud)
我不想使用字符串来访问该属性.我能做什么?
我在Typescript中有以下代码。为什么编译器会引发错误?
var object = {};
Object.defineProperty(object, 'first', {
value: 37,
writable: false,
enumerable: true,
configurable: true
});
console.log('first property: ' + object.first);
Run Code Online (Sandbox Code Playgroud)
js.ts(14,42):错误TS2339:类型“ {}”上不存在属性“ first”。
与mozilla 的文档(示例部分)中的代码段相同。