I filed this Bug Report with VSCode because I have excluded *.spec
files from compilation since I don't want to include the files in the NPM distribution.
I would still like to see that they compile correctly though via the VSCode tooling.
As it stands VSCode intellisense reports that imports that are available on the path can't be imported and this throws a lot of errors, paints the project spec files red, etc.
In my report, I said that VSCode error reporting and compilation should be two separate issues. VSCode can't both check that the file is correct and exclude it from compilation at the same time. The two are not mutually exclusive.
I have asked for triage from VSCode, but so far the issue remains closed and I wanted to see what others on SO though. Is it a bug or is the conclusion in the report correct as it stands?
IIUC, right now VS Code uses one language service instance for files not included by tsconfig.json
(including the case in which tsconfig.json
does not exist at all) with default compiler options, and when tsconfig.json
exists, it uses a second language service instance that eagerly loads all included files and uses the specified compiler options. I believe you are proposing that when tsconfig.json
exists, the first language service instance should use the compiler options from tsconfig.json
but have the same file loading behavior it has now. This would be a marginal increase in complexity, and honestly, the experience of editing files excluded from tsconfig.json
when tsconfig.json
exists would still be pretty confusing: some of your files will see global definitions and others won't, and "find all references" will give you partial results. Your proposal seems to me to be a plausible alternative to the status quo, but I don't see why you are fighting the VS Code team over it rather than just creating two tsconfig.json
files, which is explicit and gives you the unified editing experience you actually want. (Or were you proposing that there should be a single language service that ignores the excludes and eagerly loads all .ts(x?)
files under the project directory? I'm quite sure that won't fly as it will cause problems in many scenarios.)