Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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"?

like image 317
fletchsod Avatar asked Apr 27 '16 19:04

fletchsod


1 Answers

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

There's also ESLint with the no-explicit-any rule.

like image 102
Ozrix Avatar answered Oct 12 '22 09:10

Ozrix