question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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:

https://github.com/microsoft/TypeScript/issues/31181

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
Jack-Workscommented, Aug 26, 2021

@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.

0reactions
razzeeecommented, Jan 2, 2020

Thank you, that fixes compilation, after restarting VSCode

Read more comments on GitHub >

github_iconTop Results From Across the Web

Project must list all files or use an 'include' pattern
In my case I was builiding a monorepo and referencing one of the packages into another package. All I had to do was...
Read more >
tsconfig resolvejsonmodule | The Search Engine You Control
You need two different TS configs because the project is using two different environments in ... Projects must list all files or use...
Read more >
TypeScript complains about files not included, ignoring ...
I have a project using yarn workspaces with the top level tsconfig.json referencing individual ... Projects must list all files or use an...
Read more >
How to generate a tsconfig.json file | bobbyhadz
To generate a `tsconfig.json` file, open your terminal in your project's root directory. Install typescript globally: `npm install typescript@latest -g`.
Read more >
Untitled
Note: each of the workspaces (packages) need to have a package. ... file is included in, scanning folders from the file folder up...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found