打字稿配置
我是TypeScript世界的新手,因此我有一些配置问题。问题在于,即使理论上应该这样做,某些方法也无法正常工作。当前我的打字稿配置看起来如下:
{
"compilerOptions": {
"target": "ES6",
"module": "commonjs",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true,
"noEmitOnError": true,
"strictNullChecks": true,
"lib": [
"dom",
"ES2015.Collection",
"ES2015.Iterable",
"ES2016.Array.include",
"ES2017.Object",
"ES5",
"ES6",
],
}
}
除了我尝试使用示例number.isinteger()方法或array.entries()方法以下事实外,一切似乎都很好:
属性'iSinteger'不存在于类型的“ numberConstructor”上。您需要更改目标库吗?尝试将“ LIB”编译器选项更改为“ ES2015”或更高版本。
.entries()也是如此。谁能帮忙?
I'm new to the world of typeScript, hence I'm having some configuration issues. The problem is that some methods are not working even though they theoretically should. Currently my typeScript config looks as follows:
{
"compilerOptions": {
"target": "ES6",
"module": "commonjs",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true,
"noEmitOnError": true,
"strictNullChecks": true,
"lib": [
"dom",
"ES2015.Collection",
"ES2015.Iterable",
"ES2016.Array.include",
"ES2017.Object",
"ES5",
"ES6",
],
}
}
Everything seems to be fine besides the fact that when I try to use for example Number.isInteger() method or Array.entries() method following error occurs:
Property 'isInteger' does not exist on type 'NumberConstructor'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2015' or later.
The same happens with .entries(). Can anyone help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以下是来自TypeScript游乐场。如果您关注链接并切换选项,则可以弄清楚您的需求。看起来您需要更多的ES2015,当目标是ES5时,它们显示为错误。
Output
Compiler Options
Playground Link: Provided
The following is from the Typescript playground. If you follow the link and toggle the options, you can figure out what you need. Looks like you need more of ES2015, they show as errors when target is ES5.
Output
Compiler Options
Playground Link: Provided