【发布时间】:2017-08-12 01:42:34
【问题描述】:
在 Visual Studio 2017 中,我正在尝试使用 ES2015 Promises。使用 TypeScript 2.1.5。我在解决方案中有一个 tsconfig.json 文件,它看起来像这样:
{
"compilerOptions": {
"noImplicitAny": false,
"noEmitOnError": true,
"removeComments": false,
"sourceMap": true,
"target": "es5",
"outFile": "outfile.js",
"lib": [ "dom", "es2015.promise", "es5" ]
},
"exclude": [
"node_modules",
"wwwroot"
]
}
我编译,但我得到打字错误,例如:
错误 TS2339: Build:Property 'then' 在类型上不存在 '承诺'。
当我遇到错误时,我有智能感知显示它确实识别 then 函数,我可以右键单击,转到定义,这会将我带到 lib.es2015.promise.d.ts。
为什么设计时有效而编译时无效,我该如何解决?
【问题讨论】:
标签: visual-studio typescript typescript-typings tsconfig