tsconfig.json compiler options - JavaScript support Flashcards
What does allowJs
compiler option do?
Allow JavaScript files to be imported inside your project, instead of just .ts and .tsx files.
Source typescriptlang
What does checkJs
compiler option do?
Works in tandem with allowJs
. When checkJs is enabled then errors are reported in JavaScript files. This is the equivalent of including //@ts-check
at the top of all JavaScript files which are included in your project.
Source typescriptlang
What does maxNodeModuleJsDepth
compiler option do?
The maximum dependency depth to search under node_modules
and load JavaScript files.
This flag is can only be used when allowJs is enabled, and is used if you want to have TypeScript infer types for all of the JavaScript inside your node_modules
.
Ideally this should stay at 0
(the default), and d.ts
files should be used to explicitly define the shape of modules. However, there are cases where you may want to turn this on at the expense of speed and potential accuracy.
Source typescriptlang