parameter implicitly has an 'any' type

Ronin picture Ronin · Dec 16, 2017 · Viewed 55.4k times · Source

I'm using visual studio code for a typescript project, where I use some 3rd party npm js libraries. Some of them don't provide any ts types (types.d.ts file), so whenever I use parameters or variables without specifying their type, vs code's linting shows this error: parameter implicitly has an 'any' type. Also, ts wouldn't compile.

How can I prevent this from happening?

Answer

Ronin picture Ronin · Dec 16, 2017

First, to make typescript tolerate parameters without declaring their type, edit the tsconfig.json

// disable this rule:
// "strict": true,

// enable this rule:
"noImplicitAny": false

Second, install the tslint npm package as a prerequisite for the tslint vs code extension

npm install -g tslint

Third, install the tslint vs code extension