Skip to content

Possible Regression: resolveJsonModule Projects must list all files or use an 'include' pattern. #33399

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
duro opened this issue Sep 12, 2019 · 5 comments
Assignees
Labels
Question An issue which isn't directly actionable in code

Comments

@duro
Copy link

duro commented Sep 12, 2019

TypeScript Version: 3.7.0-dev.20190912

Search Terms:

resolveJsonModule Projects must list all files or use an 'include' pattern

Code

tsconfig.json

{
  "extends": "../../tsconfig.base.json",
  "compilerOptions": {
    "outDir": "./dist",
    "rootDir": "./src",
    "strictNullChecks": true,
    "resolveJsonModule": true
  },
  "include": ["src/**/*.ts", "src/**/*.json"],
  "references": []
}

tsconfig.base.json

{
  "compilerOptions": {
    "module": "commonjs",
    "target": "es2017",
    "lib": ["es2017"],
    "composite": true,
    "esModuleInterop": true,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "sourceMap": true,
    "skipLibCheck": true
  }
}

Expected behavior:

When resolveJsonModule is turned on, and json files have been included in the includes array, I should be able to import json files with no trouble.

Actual behavior:

When I use the above tsconfig options, and include a json file, I get the following error:

e2e_test_ts_—_serverless-mono

Related Issues:

#31181

@sheetalkamat
Copy link
Member

We need a repro to be able to investigate this.

@sheetalkamat sheetalkamat added the Needs More Info The issue still hasn't been fully clarified label Sep 13, 2019
@razzeee
Copy link

razzeee commented Dec 22, 2019

I'm seeing the same with this branch https://github.com/elm-tooling/elm-language-server/tree/rank

@sheetalkamat
Copy link
Member

@razzeee https://github.com/elm-tooling/elm-language-server/blob/rank/tsconfig.json#L17 is not sufficient. You have to explicitly list json files to be included. Changing that to "include": ["src", "src/**/*.json"] fixes the issue.

@razzeee
Copy link

razzeee commented Jan 2, 2020

Thank you, that fixes compilation, after restarting VSCode

@Jack-Works
Copy link
Contributor

@razzeee https://github.com/elm-tooling/elm-language-server/blob/rank/tsconfig.json#L17 is not sufficient. You have to explicitly list json files to be included. Changing that to "include": ["src", "src/**/*.json"] fixes the issue.

Why do I need to do that even I have --resolveJsonModule on?

If a glob pattern doesn’t include a file extension, then only files with supported extensions are included (e.g. .ts, .tsx, and .d.ts by default, with .js and .jsx if allowJs is set to true).

In the document of includes. I think .json should be included too when resolveJsonModule is on.

@RyanCavanaugh RyanCavanaugh added Question An issue which isn't directly actionable in code and removed Needs More Info The issue still hasn't been fully clarified labels Aug 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question An issue which isn't directly actionable in code
Projects
None yet
Development

No branches or pull requests

5 participants