Description
Background we want to enable checkJS in a folder that contains JS code inside the vscode repository microsoft/vscode#41953. This folder is a hybrid TS and JS folder and would be a good application for enabling checkJS.
However, setting checkJS
to true without setting allowJS
to true in a tsconfig.json
file has no effect:
checking happens when both attributes are true:
no checking when allowJS is set to false:
Defining allowJS to true for this folder has the side effect that the compiler wants to emit transpiled JS files and would overwrite the existing JS files. Having to change the project structure to use an output folder should not be required when enabling checkJS and I haven´t found a way to specify noEmit
only for JS files.
Therefore, it must be possible to check JS files using the project context defined in the tsconfig.json without that the JS files are transpiled and code is emitted.
We have tried to work around this by adding //@ts-check
comments to the JS files. However, this has the side effect that the project context defined in the tsconfig.json is ignored. This results in nasty issues that a typings file is used from the global type cache but not from a typings file that is included in a child folder of the tsconfig.json folder. This results in false errors.
Related #16738 but this issue proposes to automatically enable allowJS when checkJS is enabled. The issue here is about enabling checkJS without transpiling the JS files and generating code.