Skip to content

TSServer reports TS6307 in composite projects on JSON files included via include pattern #33827

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
lierdakil opened this issue Oct 5, 2019 · 3 comments · Fixed by #34676
Closed
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue

Comments

@lierdakil
Copy link

TypeScript Version: 3.6.3, actually most likely all versions since v3.2

Search Terms: composite, resolveJSONModule, tsserver, TS6307, include pattern

Code

Not particularly easy to show with code, but here's a repro:

https://github.com/lierdakil/ts6307-composite-json-tsserver-test

  1. Clone
  2. Run npm install
  3. Run node test.js in a terminal
  4. Observe output
  5. Kill test.js (ctrl+C or whathaveyou)

Note: test.js just spawns tsserver and tells it to open src/test.ts.

Please see README for a complete listing.

Expected behavior:

No error diagnostics.

Actual behavior:

In tsserver output, we see:

{"seq":0,"type":"event","event":"configFileDiag","body":{"triggerFile":"src/test.ts","configFile":"tsconfig.json","diagnostics":[{"text":"File '/tmp/test/src/blabla.json' is not listed within the file list of project 'tsconfig.json'. Projects must list all files or use an 'include' pattern.","code":6307,"category":"error"}]}}

That is, TS6307 on a JSON file, which is included in the project via include pattern.

Additional observations:

  • Issue only manifests when composite: true.
  • Issue only manifests in tsserver, but not in tsc itself.
  • Issue only manifests when tsconfig.json uses include, but not when it uses files.

Related Issues:
#25636 #30785, also see PR #27844

Other related issues (from external projects):
TypeStrong/ts-loader#905
TypeStrong/atom-typescript#1512

@sheetalkamat
Copy link
Member

Looks like https://github.com/microsoft/TypeScript/blob/master/src/services/services.ts#L956 is causing this

@pcowgill
Copy link

Is this fix live on npm yet?

@youngderekm
Copy link

I still see a variation of this bug in recent versions. In our case, we have composite: true and resolveJsonModule: true. We have a bunch of .json files in our source tree and our include pattern is like so:

  "include": [
    "webapp/",
    "webapp/**/*.json",
  ],

However, we don't have any uses of .ts files importing .json files, at the moment. Still, tsserver returns lots of TS6307 errors for many different imports of ts/tsx files within the webapp directory. The imported files don't have .json files with the same name. IntelliJ shows lots of imports that say files are not listed within the file list (TS6307) for .ts or .tsx files in webapp/. It looks almost random, and commenting out one import line causes different import lines to show this error. Restarting tsserver does not correct the the problem. Compiling from tsc works with no errors.

If you then comment out the pattern "webapp/**/*.json" from tsconfig.json, all TS6307 errors in the IDE go away.

I see this with 4.2.3, and also tried with 4.5.5 and the problem remains.

JanJakes added a commit to mailpoet/mailpoet that referenced this issue Feb 15, 2023
Due to microsoft/TypeScript#33827 we need to explicitly
name JSON files in the "include" array, until we upgrade to a more recent TypeScript.

[MAILPOET-5015]
JanJakes added a commit to mailpoet/mailpoet that referenced this issue Mar 16, 2023
Due to microsoft/TypeScript#33827 we need to explicitly
name JSON files in the "include" array, until we upgrade to a more recent TypeScript.

[MAILPOET-5015]
JanJakes added a commit to mailpoet/mailpoet that referenced this issue Mar 16, 2023
Due to microsoft/TypeScript#33827 we need to explicitly
name JSON files in the "include" array, until we upgrade to a more recent TypeScript.

[MAILPOET-5015]
JanJakes added a commit to mailpoet/mailpoet that referenced this issue Mar 20, 2023
Due to microsoft/TypeScript#33827 we need to explicitly
name JSON files in the "include" array, until we upgrade to a more recent TypeScript.

[MAILPOET-5015]
JanJakes added a commit to mailpoet/mailpoet that referenced this issue Mar 20, 2023
Due to microsoft/TypeScript#33827 we need to explicitly
name JSON files in the "include" array, until we upgrade to a more recent TypeScript.

[MAILPOET-5015]
JanJakes added a commit to mailpoet/mailpoet that referenced this issue Mar 22, 2023
Due to microsoft/TypeScript#33827 we need to explicitly
name JSON files in the "include" array, until we upgrade to a more recent TypeScript.

[MAILPOET-5015]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants