Does typescript have an option to disallow “any” when declaring or cast/conversion?

泄露秘密 提交于 2020-05-27 05:36:08

问题


I'm using TypeScript version 1.8.10 in Visual Studio 2015.

In tsconfig.json I have those settings as

"compilerOptions": {
  "target": "es6",
  "module": "system",
  "moduleResolution": "node",
  "emitDecoratorMetadata": true,
  "experimentalDecorators": true,
  "removeComments": true,
  "noImplicitAny": true,
  "noEmitOnError": false,
  "noImplicitUseStrict": false,
  "declaration": false,
  "inlineSourceMap": true,
  "inlineSources": true
},

I'm wondering is is there a setting that disallow the use of "any" and force us to use datatype such as number, string, etc. instead of "any"?


回答1:


You could use TSlint in conjunction with TypeScript and set the no-any flag. See https://www.npmjs.com/package/tslint (search for no-any)



来源:https://stackoverflow.com/questions/36898828/does-typescript-have-an-option-to-disallow-any-when-declaring-or-cast-conversi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!