Skip to content
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

tsconfig v0.5 regression with json imports #27

Closed
cexbrayat opened this issue Dec 17, 2023 · 1 comment
Closed

tsconfig v0.5 regression with json imports #27

cexbrayat opened this issue Dec 17, 2023 · 1 comment

Comments

@cexbrayat
Copy link
Member

Let's say a file contains a JSON import:

import en from '@/locales/en.json';

then the type-check throws with:

src/i18n.ts:2:16 - error TS6307: File '/home/projects/github-nzwcnu/src/locales/en.json' is not listed within the file list of project '/home/projects/github-nzwcnu/tsconfig.vitest.json'. Projects must list all files or use an 'include' pattern.

2 import en from '@/locales/en.json';

Reverting to v0.4 makes the error go away.

See https://stackblitz.com/edit/github-nzwcnu?file=src%2Fi18n.ts for a small repro
Run npm i and npm run type-check

@haoqunjiang
Copy link
Member

haoqunjiang commented Dec 18, 2023

The direct cause is outDir. But the underlying issue is a bit confusing:

  • composite option enforces an additional constraint that all files must be matched by inlcude or included in files. https://www.typescriptlang.org/tsconfig#composite
  • Somehow TypeScript doesn't think src/**/* actually match .json
  • When src/**/*.json is added to the include patterns, it works again. But that's not a viable fix. Vite supports so many different suffixes…

I'll see if it's a TS bug or if we can work around it in another way.

haoqunjiang added a commit to vuejs/create-vue that referenced this issue Dec 20, 2023
To avoid polluting the root directory with tsconfig.*.tsbuildinfo files.

`outDir` in the base config doesn't work because of vuejs/tsconfig#27 (comment)
Besides, we need this explicit config in `tsconfig.node.json` anyways,
as it doesn't extend from `@vue/tsconfig`.

Using `.tmp` instead of `.cache` here to better indicate the purpose.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants