Search code examples
typescriptvisual-studio-codetypescript-typings

parameter implicitly has an 'any' type


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?


Solution

  • 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 VSCode extension

    npm install -g tslint
    

    Third, install the tslint VSCode extension