Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why TSC shows the errors on dependency module typings

Tags:

typescript

I'm using some dependency for my app say module fuse-box

tsconfig:

{
  "compilerOptions": {
    "noImplicitAny": true
  },
  "exclude": [
    "**/node_modules/*", 
  ]
}

one of files in my codebase:

import { FuseBox } from 'fuse-box'

FuseBox.init({
  homeDir: '.',
  outFile: './built/out.js'
}).bundle('>app.ts')

TSC compiler gives me the error:

../node_modules/fuse-box/dist/typings/c
ore/WorkflowContext.d.ts(137,9): error TS7020: Call signature, which lacks retu
rn-type annotation, implicitly has an 'any' return type.

It is because of my noImplicitAny": true settings. I just wonder why the hell it analyzes the stuff that out of my codebase and prints the error. Are such errors safe for dev process and compilation?

like image 766
WHITECOLOR Avatar asked Mar 21 '17 17:03

WHITECOLOR


1 Answers

The compiler needs to go through the modules typing to give the proper type checking for you.

If you want to turn it off, you can do this in your tsconfig.json:

{
  "compilerOptions": {
    "skipLibCheck": true
  }
}

This requires TypeScript 2.0

UPDATE: As usage of TypeScript increase and the use cases expended, we start seeing issues even with skipLibCheck is set to true.

One of the issues is that it does not skip check in node_modules if the package includes .ts files.

The issue is marked as working as intended.

Furthermore, you will hit with compilation error if the TypeScript version used by the package are different then what you are using, and there are breaking changes between them.

like image 104
unional Avatar answered Oct 22 '22 05:10

unional