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

jsconfig.json not respecting the exclude directory. #42797

Closed
roebuk opened this issue Feb 14, 2021 · 8 comments
Closed

jsconfig.json not respecting the exclude directory. #42797

roebuk opened this issue Feb 14, 2021 · 8 comments
Labels
Question An issue which isn't directly actionable in code

Comments

@roebuk
Copy link

roebuk commented Feb 14, 2021

Bug Report

🔎 Search Terms

jsconfig.json exclude
jsconfig.json node_modules

🕗 Version & Regression Information

tested typescript versions 4.0.0, 4.1.5, 4.3.0-dev.20210214

  • This is a bug

💻 Code

There's a sample repo here https://github.com/roebuk/jsconfig-issue

Clone, install dependencies, then run the two different npm scripts:

"check-types-js": "tsc -p jsconfig.json",
"check-types-ts": "tsc -p tsconfig.json",

🙁 Actual behavior

Running tsc -p jsconfig.json should respect the "exclude": ["node_modules"] settings and not report errors within node_modules.

../node_modules/url/url.js:729:41 - error TS2531: Object is possibly 'null'.

729     host = host.substr(0, host.length - port.length);
                                            ~~~~
Found 4325 errors.

🙂 Expected behavior

It should not report errors within node_modules, just like the running tsc -p tsconfig.json

@MartinJohns
Copy link
Contributor

Imported files are always included, and I would guess that you indirectly import the url module via React. You can try running the CLI with the --traceResolution argument.

@roebuk
Copy link
Author

roebuk commented Feb 15, 2021

Here's the initial output from --traceResolution.

> [email protected] check-types-js
> tsc -p jsconfig.json --traceResolution

======== Resolving module 'react' from 'example/src/Header.js'. ========
Module resolution kind is not specified, using 'NodeJs'.
Loading module 'react' from 'node_modules' folder, target file type 'TypeScript'.
Directory 'example/src/node_modules' does not exist, skipping all lookups in it.
Found 'package.json' at 'example/node_modules/react/package.json'.
'package.json' does not have a 'typesVersions' field.
File 'example/node_modules/react.ts' does not exist.
File 'example/node_modules/react.tsx' does not exist.
File 'example/node_modules/react.d.ts' does not exist.
'package.json' does not have a 'typings' field.
'package.json' does not have a 'types' field.
'package.json' has 'main' field 'index.js' that references 'example/node_modules/react/index.js'.
File 'example/node_modules/react/index.js' exist - use it as a name resolution result.File 'example/node_modules/react/index.js' has an unsupported extension, so skipping it.
Loading module as file / folder, candidate module location 'example/node_modules/react/index.js', target file type 'TypeScript'.
File 'example/node_modules/react/index.js.ts' does not exist.
File 'example/node_modules/react/index.js.tsx' does not exist.
File 'example/node_modules/react/index.js.d.ts' does not exist.
File name 'example/node_modules/react/index.js' has a '.js' extension - stripping it.
File 'example/node_modules/react/index.ts' does not exist.
File 'example/node_modules/react/index.tsx' does not exist.
File 'example/node_modules/react/index.d.ts' does not exist.
Directory 'example/node_modules/react/index.js' does not exist, skipping all lookups in it.
File 'example/node_modules/react/index.ts' does not exist.
File 'example/node_modules/react/index.tsx' does not exist.
File 'example/node_modules/react/index.d.ts' does not exist.
File 'example/node_modules/@types/react.d.ts' does not exist.
Directory 'node_modules' does not exist, skipping all lookups in it.
File 'node_modules/react.ts' does not exist.
File 'node_modules/react.tsx' does not exist.
File 'node_modules/react.d.ts' does not exist.
Directory 'node_modules/@types' does not exist, skipping all lookups in it.
Directory 'node_modules' does not exist, skipping all lookups in it.
Directory 'node_modules' does not exist, skipping all lookups in it.
Loading module 'react' from 'node_modules' folder, target file type 'JavaScript'.
Directory 'example/src/node_modules' does not exist, skipping all lookups in it.
Found 'package.json' at 'example/node_modules/react/package.json'.
'package.json' does not have a 'typesVersions' field.
File 'example/node_modules/react.js' does not exist.
File 'example/node_modules/react.jsx' does not exist.
'package.json' has 'main' field 'index.js' that references 'example/node_modules/react/index.js'.
File 'example/node_modules/react/index.js' exist - use it as a name resolution result.Resolving real path for 'example/node_modules/react/index.js', result 'example/node_modules/react/index.js'.
======== Module name 'react' was successfully resolved to 'example/node_modules/react/index.js' with Package ID 'react/[email protected]'. ========
======== Resolving module './cjs/react.production.min.js' from 'example/node_modules/react/index.js'. ========
Module resolution kind is not specified, using 'NodeJs'.
Loading module as file / folder, candidate module location 'example/node_modules/react/cjs/react.production.min.js', target file type 'TypeScript'.
File 'example/node_modules/react/cjs/react.production.min.js.ts' does not exist.
File 'example/node_modules/react/cjs/react.production.min.js.tsx' does not exist.
File 'example/node_modules/react/cjs/react.production.min.js.d.ts' does not exist.
File name 'example/node_modules/react/cjs/react.production.min.js' has a '.js' extension - stripping it.
File 'example/node_modules/react/cjs/react.production.min.ts' does not exist.
File 'example/node_modules/react/cjs/react.production.min.tsx' does not exist.
File 'example/node_modules/react/cjs/react.production.min.d.ts' does not exist.
Directory 'example/node_modules/react/cjs/react.production.min.js' does not exist, skipping all lookups in it.
Loading module as file / folder, candidate module location 'example/node_modules/react/cjs/react.production.min.js', target file type 'JavaScript'.
File 'example/node_modules/react/cjs/react.production.min.js.js' does not exist.
File 'example/node_modules/react/cjs/react.production.min.js.jsx' does not exist.
File name 'example/node_modules/react/cjs/react.production.min.js' has a '.js' extension - stripping it.
File 'example/node_modules/react/cjs/react.production.min.js' exist - use it as a name resolution result.
Found 'package.json' at 'example/node_modules/react/package.json'.
'package.json' does not have a 'typesVersions' field.
======== Module name './cjs/react.production.min.js' was successfully resolved to 'example/node_modules/react/cjs/react.production.min.js' with Package ID 'react/cjs/[email protected]'. ========
======== Resolving module './cjs/react.development.js' from 'example/node_modules/react/index.js'. ========
Module resolution kind is not specified, using 'NodeJs'.
Loading module as file / folder, candidate module location 'example/node_modules/react/cjs/react.development.js', target file type 'TypeScript'.
File 'example/node_modules/react/cjs/react.development.js.ts' does not exist.
File 'example/node_modules/react/cjs/react.development.js.tsx' does not exist.
File 'example/node_modules/react/cjs/react.development.js.d.ts' does not exist.
File name 'example/node_modules/react/cjs/react.development.js' has a '.js' extension - stripping it.
File 'example/node_modules/react/cjs/react.development.ts' does not exist.
File 'example/node_modules/react/cjs/react.development.tsx' does not exist.
File 'example/node_modules/react/cjs/react.development.d.ts' does not exist.
Directory 'example/node_modules/react/cjs/react.development.js' does not exist, skipping all lookups in it.
Loading module as file / folder, candidate module location 'example/node_modules/react/cjs/react.development.js', target file type 'JavaScript'.
File 'example/node_modules/react/cjs/react.development.js.js' does not exist.
File 'example/node_modules/react/cjs/react.development.js.jsx' does not exist.
File name 'example/node_modules/react/cjs/react.development.js' has a '.js' extension - stripping it.
File 'example/node_modules/react/cjs/react.development.js' exist - use it as a name resolution result.
Found 'package.json' at 'example/node_modules/react/package.json'.
'package.json' does not have a 'typesVersions' field.
======== Module name './cjs/react.development.js' was successfully resolved to 'example/node_modules/react/cjs/react.development.js' with Package ID 'react/cjs/[email protected]'. ========
======== Resolving module 'object-assign' from 'example/node_modules/react/cjs/react.production.min.js'. ========
Module resolution kind is not specified, using 'NodeJs'.
Loading module 'object-assign' from 'node_modules' folder, target file type 'TypeScript'.
Directory 'example/node_modules/react/cjs/node_modules' does not exist, skipping all lookups in it.
Directory 'example/node_modules/react/node_modules' does not exist, skipping all lookups in it.
Found 'package.json' at 'example/node_modules/object-assign/package.json'.
'package.json' does not have a 'typesVersions' field.
File 'example/node_modules/object-assign.ts' does not exist.
File 'example/node_modules/object-assign.tsx' does not exist.
File 'example/node_modules/object-assign.d.ts' does not exist.
'package.json' does not have a 'typings' field.
'package.json' does not have a 'types' field.
'package.json' does not have a 'main' field.
File 'example/node_modules/object-assign/index.ts' does not exist.
File 'example/node_modules/object-assign/index.tsx' does not exist.
File 'example/node_modules/object-assign/index.d.ts' does not exist.
File 'example/node_modules/@types/object-assign.d.ts' does not exist.
Directory 'node_modules' does not exist, skipping all lookups in it.
File 'node_modules/object-assign.ts' does not exist.
File 'node_modules/object-assign.tsx' does not exist.
File 'node_modules/object-assign.d.ts' does not exist.
Directory 'node_modules/@types' does not exist, skipping all lookups in it.
Directory 'node_modules' does not exist, skipping all lookups in it.
Directory 'node_modules' does not exist, skipping all lookups in it.
Loading module 'object-assign' from 'node_modules' folder, target file type 'JavaScript'.
Directory 'example/node_modules/react/cjs/node_modules' does not exist, skipping all lookups in it.
Directory 'example/node_modules/react/node_modules' does not exist, skipping all lookups in it.
Found 'package.json' at 'example/node_modules/object-assign/package.json'.
'package.json' does not have a 'typesVersions' field.
File 'example/node_modules/object-assign.js' does not exist.
File 'example/node_modules/object-assign.jsx' does not exist.
'package.json' does not have a 'main' field.
File 'example/node_modules/object-assign/index.js' exist - use it as a name resolution result.
Resolving real path for 'example/node_modules/object-assign/index.js', result 'example/node_modules/object-assign/index.js'.
======== Module name 'object-assign' was successfully resolved to 'example/node_modules/object-assign/index.js' with Package ID 'object-assign/[email protected]'. ========
======== Resolving module 'object-assign' from 'example/node_modules/react/cjs/react.development.js'. ========
Resolution for module 'object-assign' was found in cache from location 'example/node_modules/react/cjs'.
======== Module name 'object-assign' was successfully resolved to 'example/node_modules/object-assign/index.js' with Package ID 'object-assign/[email protected]'. ========
======== Resolving module 'react' from 'example/src/index.js'. ========
Resolution for module 'react' was found in cache from location 'example/src'.
======== Module name 'react' was successfully resolved to 'example/node_modules/react/index.js' with Package ID 'react/[email protected]'. ========
======== Resolving module 'react-dom' from 'example/src/index.js'. ========
Module resolution kind is not specified, using 'NodeJs'.
Loading module 'react-dom' from 'node_modules' folder, target file type 'TypeScript'.
Directory 'example/src/node_modules' does not exist, skipping all lookups in it.
Found 'package.json' at 'example/node_modules/react-dom/package.json'.
'package.json' does not have a 'typesVersions' field.
File 'example/node_modules/react-dom.ts' does not exist.
File 'example/node_modules/react-dom.tsx' does not exist.
File 'example/node_modules/react-dom.d.ts' does not exist.
'package.json' does not have a 'typings' field.
'package.json' does not have a 'types' field.
'package.json' has 'main' field 'index.js' that references 'example/node_modules/react-dom/index.js'.
File 'example/node_modules/react-dom/index.js' exist - use it as a name resolution result.
File 'example/node_modules/react-dom/index.js' has an unsupported extension, so skipping it.
Loading module as file / folder, candidate module location 'example/node_modules/react-dom/index.js', target file type 'TypeScript'.
File 'example/node_modules/react-dom/index.js.ts' does not exist.
File 'example/node_modules/react-dom/index.js.tsx' does not exist.
File 'example/node_modules/react-dom/index.js.d.ts' does not exist.
File name 'example/node_modules/react-dom/index.js' has a '.js' extension - stripping it.
File 'example/node_modules/react-dom/index.ts' does not exist.
File 'example/node_modules/react-dom/index.tsx' does not exist.
File 'example/node_modules/react-dom/index.d.ts' does not exist.
Directory 'example/node_modules/react-dom/index.js' does not exist, skipping all lookups in it.
File 'example/node_modules/react-dom/index.ts' does not exist.
File 'example/node_modules/react-dom/index.tsx' does not exist.
File 'example/node_modules/react-dom/index.d.ts' does not exist.
File 'example/node_modules/@types/react-dom.d.ts' does not exist.
Directory 'node_modules' does not exist, skipping all lookups in it.
File 'node_modules/react-dom.ts' does not exist.
File 'node_modules/react-dom.tsx' does not exist.
File 'node_modules/react-dom.d.ts' does not exist.
Directory 'node_modules/@types' does not exist, skipping all lookups in it.
Directory 'node_modules' does not exist, skipping all lookups in it.
Directory 'node_modules' does not exist, skipping all lookups in it.
Loading module 'react-dom' from 'node_modules' folder, target file type 'JavaScript'.
Directory 'example/src/node_modules' does not exist, skipping all lookups in it.
Found 'package.json' at 'example/node_modules/react-dom/package.json'.
'package.json' does not have a 'typesVersions' field.
File 'example/node_modules/react-dom.js' does not exist.
File 'example/node_modules/react-dom.jsx' does not exist.
'package.json' has 'main' field 'index.js' that references 'example/node_modules/react-dom/index.js'.
File 'example/node_modules/react-dom/index.js' exist - use it as a name resolution result.
Resolving real path for 'example/node_modules/react-dom/index.js', result 'example/node_modules/react-dom/index.js'.
======== Module name 'react-dom' was successfully resolved to 'example/node_modules/react-dom/index.js' with Package ID 'react-dom/[email protected]'. ========
======== Resolving module './cjs/react-dom.production.min.js' from 'example/node_modules/react-dom/index.js'. ========
Module resolution kind is not specified, using 'NodeJs'.
Loading module as file / folder, candidate module location 'example/node_modules/react-dom/cjs/react-dom.production.min.js', target file type 'TypeScript'.
File 'example/node_modules/react-dom/cjs/react-dom.production.min.js.ts' does not exist.
File 'example/node_modules/react-dom/cjs/react-dom.production.min.js.tsx' does not exist.
File 'example/node_modules/react-dom/cjs/react-dom.production.min.js.d.ts' does not exist.
File name 'example/node_modules/react-dom/cjs/react-dom.production.min.js' has a '.js' extension - stripping it.
File 'example/node_modules/react-dom/cjs/react-dom.production.min.ts' does not exist.
File 'example/node_modules/react-dom/cjs/react-dom.production.min.tsx' does not exist.File 'example/node_modules/react-dom/cjs/react-dom.production.min.d.ts' does not exist.
Directory 'example/node_modules/react-dom/cjs/react-dom.production.min.js' does not exist, skipping all lookups in it.
Loading module as file / folder, candidate module location 'example/node_modules/react-dom/cjs/react-dom.production.min.js', target file type 'JavaScript'.
File 'example/node_modules/react-dom/cjs/react-dom.production.min.js.js' does not exist.
File 'example/node_modules/react-dom/cjs/react-dom.production.min.js.jsx' does not exist.
File name 'example/node_modules/react-dom/cjs/react-dom.production.min.js' has a '.js' extension - stripping it.
File 'example/node_modules/react-dom/cjs/react-dom.production.min.js' exist - use it as a name resolution result.
Found 'package.json' at 'example/node_modules/react-dom/package.json'.
'package.json' does not have a 'typesVersions' field.
======== Module name './cjs/react-dom.production.min.js' was successfully resolved to 'example/node_modules/react-dom/cjs/react-dom.production.min.js' with Package ID 'react-dom/cjs/[email protected]'. ========
======== Resolving module './cjs/react-dom.development.js' from 'example/node_modules/react-dom/index.js'. ========
Module resolution kind is not specified, using 'NodeJs'.
Loading module as file / folder, candidate module location 'example/node_modules/react-dom/cjs/react-dom.development.js', target file type 'TypeScript'.
File 'example/node_modules/react-dom/cjs/react-dom.development.js.ts' does not exist.
File 'example/node_modules/react-dom/cjs/react-dom.development.js.tsx' does not exist.File 'example/node_modules/react-dom/cjs/react-dom.development.js.d.ts' does not exist.
File name 'example/node_modules/react-dom/cjs/react-dom.development.js' has a '.js' extension - stripping it.
File 'example/node_modules/react-dom/cjs/react-dom.development.ts' does not exist.
File 'example/node_modules/react-dom/cjs/react-dom.development.tsx' does not exist.
File 'example/node_modules/react-dom/cjs/react-dom.development.d.ts' does not exist.
Directory 'example/node_modules/react-dom/cjs/react-dom.development.js' does not exist, skipping all lookups in it.
Loading module as file / folder, candidate module location 'example/node_modules/react-dom/cjs/react-dom.development.js', target file type 'JavaScript'.
File 'example/node_modules/react-dom/cjs/react-dom.development.js.js' does not exist.
File 'example/node_modules/react-dom/cjs/react-dom.development.js.jsx' does not exist.File name 'example/node_modules/react-dom/cjs/react-dom.development.js' has a '.js' extension - stripping it.
File 'example/node_modules/react-dom/cjs/react-dom.development.js' exist - use it as a name resolution result.
Found 'package.json' at 'example/node_modules/react-dom/package.json'.
'package.json' does not have a 'typesVersions' field.
======== Module name './cjs/react-dom.development.js' was successfully resolved to 'example/node_modules/react-dom/cjs/react-dom.development.js' with Package ID 'react-dom/cjs/[email protected]'. ========
======== Resolving module 'react' from 'example/node_modules/react-dom/cjs/react-dom.production.min.js'. ========
Module resolution kind is not specified, using 'NodeJs'.
Loading module 'react' from 'node_modules' folder, target file type 'TypeScript'.
Directory 'example/node_modules/react-dom/cjs/node_modules' does not exist, skipping all lookups in it.
Directory 'example/node_modules/react-dom/node_modules' does not exist, skipping all lookups in it.
Resolution for module 'react' was found in cache from location 'example'.
======== Module name 'react' was successfully resolved to 'example/node_modules/react/index.js' with Package ID 'react/[email protected]'. ========
======== Resolving module 'object-assign' from 'example/node_modules/react-dom/cjs/react-dom.production.min.js'. ========
Module resolution kind is not specified, using 'NodeJs'.
Loading module 'object-assign' from 'node_modules' folder, target file type 'TypeScript'.
Directory 'example/node_modules/react-dom/cjs/node_modules' does not exist, skipping all lookups in it.
Directory 'example/node_modules/react-dom/node_modules' does not exist, skipping all lookups in it.
Found 'package.json' at 'example/node_modules/object-assign/package.json'.
'package.json' does not have a 'typesVersions' field.
File 'example/node_modules/object-assign.ts' does not exist.
File 'example/node_modules/object-assign.tsx' does not exist.
File 'example/node_modules/object-assign.d.ts' does not exist.
'package.json' does not have a 'typings' field.
'package.json' does not have a 'types' field.
'package.json' does not have a 'main' field.
File 'example/node_modules/object-assign/index.ts' does not exist.
File 'example/node_modules/object-assign/index.tsx' does not exist.
File 'example/node_modules/object-assign/index.d.ts' does not exist.
File 'example/node_modules/@types/object-assign.d.ts' does not exist.
Directory 'node_modules' does not exist, skipping all lookups in it.
File 'node_modules/object-assign.ts' does not exist.
File 'node_modules/object-assign.tsx' does not exist.
File 'node_modules/object-assign.d.ts' does not exist.
Directory 'node_modules/@types' does not exist, skipping all lookups in it.
Directory 'node_modules' does not exist, skipping all lookups in it.
Directory 'node_modules' does not exist, skipping all lookups in it.
Loading module 'object-assign' from 'node_modules' folder, target file type 'JavaScript'.
Directory 'example/node_modules/react-dom/cjs/node_modules' does not exist, skipping all lookups in it.
Directory 'example/node_modules/react-dom/node_modules' does not exist, skipping all lookups in it.
Found 'package.json' at 'example/node_modules/object-assign/package.json'.
'package.json' does not have a 'typesVersions' field.
File 'example/node_modules/object-assign.js' does not exist.
File 'example/node_modules/object-assign.jsx' does not exist.
'package.json' does not have a 'main' field.
File 'example/node_modules/object-assign/index.js' exist - use it as a name resolution result.
Resolving real path for 'example/node_modules/object-assign/index.js', result 'example/node_modules/object-assign/index.js'.
======== Module name 'object-assign' was successfully resolved to 'example/node_modules/object-assign/index.js' with Package ID 'object-assign/[email protected]'. ========
======== Resolving module 'scheduler' from 'example/node_modules/react-dom/cjs/react-dom.production.min.js'. ========
Module resolution kind is not specified, using 'NodeJs'.
Loading module 'scheduler' from 'node_modules' folder, target file type 'TypeScript'.
Directory 'example/node_modules/react-dom/cjs/node_modules' does not exist, skipping all lookups in it.
Directory 'example/node_modules/react-dom/node_modules' does not exist, skipping all lookups in it.
Found 'package.json' at 'example/node_modules/scheduler/package.json'.
'package.json' does not have a 'typesVersions' field.
File 'example/node_modules/scheduler.ts' does not exist.
File 'example/node_modules/scheduler.tsx' does not exist.
File 'example/node_modules/scheduler.d.ts' does not exist.
'package.json' does not have a 'typings' field.
'package.json' does not have a 'types' field.
'package.json' has 'main' field 'index.js' that references 'example/node_modules/scheduler/index.js'.
File 'example/node_modules/scheduler/index.js' exist - use it as a name resolution result.
File 'example/node_modules/scheduler/index.js' has an unsupported extension, so skipping it.
Loading module as file / folder, candidate module location 'example/node_modules/scheduler/index.js', target file type 'TypeScript'.
File 'example/node_modules/scheduler/index.js.ts' does not exist.
File 'example/node_modules/scheduler/index.js.tsx' does not exist.
File 'example/node_modules/scheduler/index.js.d.ts' does not exist.
File name 'example/node_modules/scheduler/index.js' has a '.js' extension - stripping it.
File 'example/node_modules/scheduler/index.ts' does not exist.
File 'example/node_modules/scheduler/index.tsx' does not exist.
File 'example/node_modules/scheduler/index.d.ts' does not exist.
Directory 'example/node_modules/scheduler/index.js' does not exist, skipping all lookups in it.
File 'example/node_modules/scheduler/index.ts' does not exist.
File 'example/node_modules/scheduler/index.tsx' does not exist.
File 'example/node_modules/scheduler/index.d.ts' does not exist.
File 'example/node_modules/@types/scheduler.d.ts' does not exist.
Directory 'node_modules' does not exist, skipping all lookups in it.
File 'node_modules/scheduler.ts' does not exist.
File 'node_modules/scheduler.tsx' does not exist.
File 'node_modules/scheduler.d.ts' does not exist.
Directory 'node_modules/@types' does not exist, skipping all lookups in it.
Directory 'node_modules' does not exist, skipping all lookups in it.
Directory 'node_modules' does not exist, skipping all lookups in it.
Loading module 'scheduler' from 'node_modules' folder, target file type 'JavaScript'.
Directory 'example/node_modules/react-dom/cjs/node_modules' does not exist, skipping all lookups in it.
Directory 'example/node_modules/react-dom/node_modules' does not exist, skipping all lookups in it.
Found 'package.json' at 'example/node_modules/scheduler/package.json'.
'package.json' does not have a 'typesVersions' field.
File 'example/node_modules/scheduler.js' does not exist.
File 'example/node_modules/scheduler.jsx' does not exist.
'package.json' has 'main' field 'index.js' that references 'example/node_modules/scheduler/index.js'.
File 'example/node_modules/scheduler/index.js' exist - use it as a name resolution result.
Resolving real path for 'example/node_modules/scheduler/index.js', result 'example/node_modules/scheduler/index.js'.
======== Module name 'scheduler' was successfully resolved to 'example/node_modules/scheduler/index.js' with Package ID 'scheduler/[email protected]'. ========
======== Resolving module 'react' from 'example/node_modules/react-dom/cjs/react-dom.development.js'. ========
Resolution for module 'react' was found in cache from location 'example/node_modules/react-dom/cjs'.
======== Module name 'react' was successfully resolved to 'example/node_modules/react/index.js' with Package ID 'react/[email protected]'. ========
======== Resolving module 'object-assign' from 'example/node_modules/react-dom/cjs/react-dom.development.js'. ========
Resolution for module 'object-assign' was found in cache from location 'example/node_modules/react-dom/cjs'.
======== Module name 'object-assign' was successfully resolved to 'example/node_modules/object-assign/index.js' with Package ID 'object-assign/[email protected]'. ========
======== Resolving module 'scheduler' from 'example/node_modules/react-dom/cjs/react-dom.development.js'. ========
Resolution for module 'scheduler' was found in cache from location 'example/node_modules/react-dom/cjs'.
======== Module name 'scheduler' was successfully resolved to 'example/node_modules/scheduler/index.js' with Package ID 'scheduler/[email protected]'. ========
======== Resolving module 'scheduler/tracing' from 'example/node_modules/react-dom/cjs/react-dom.development.js'. ========
Module resolution kind is not specified, using 'NodeJs'.
Loading module 'scheduler/tracing' from 'node_modules' folder, target file type 'TypeScript'.
Directory 'example/node_modules/react-dom/cjs/node_modules' does not exist, skipping all lookups in it.
Directory 'example/node_modules/react-dom/node_modules' does not exist, skipping all lookups in it.
Found 'package.json' at 'example/node_modules/scheduler/package.json'.
'package.json' does not have a 'typesVersions' field.
File 'example/node_modules/scheduler/tracing.ts' does not exist.
File 'example/node_modules/scheduler/tracing.tsx' does not exist.
File 'example/node_modules/scheduler/tracing.d.ts' does not exist.
'package.json' does not have a 'typings' field.
'package.json' does not have a 'types' field.
'package.json' has 'main' field 'index.js' that references 'example/node_modules/scheduler/tracing/index.js'.
Loading module as file / folder, candidate module location 'example/node_modules/scheduler/tracing/index.js', target file type 'TypeScript'.
File name 'example/node_modules/scheduler/tracing/index.js' has a '.js' extension - stripping it.
Directory 'node_modules' does not exist, skipping all lookups in it.
Directory 'node_modules/@types' does not exist, skipping all lookups in it.
Directory 'node_modules' does not exist, skipping all lookups in it.
Directory 'node_modules' does not exist, skipping all lookups in it.
Loading module 'scheduler/tracing' from 'node_modules' folder, target file type 'JavaScript'.
Directory 'example/node_modules/react-dom/cjs/node_modules' does not exist, skipping all lookups in it.
Directory 'example/node_modules/react-dom/node_modules' does not exist, skipping all lookups in it.
Found 'package.json' at 'example/node_modules/scheduler/package.json'.
'package.json' does not have a 'typesVersions' field.
File 'example/node_modules/scheduler/tracing.js' exist - use it as a name resolution result.
Resolving real path for 'example/node_modules/scheduler/tracing.js', result 'example/node_modules/scheduler/tracing.js'.
======== Module name 'scheduler/tracing' was successfully resolved to 'example/node_modules/scheduler/tracing.js' with Package ID 'scheduler/[email protected]'. ========
======== Resolving type reference directive 'q', containing file 'example/__inferred type names__.ts', root directory 'example/node_modules/@types'. ========
Resolving with primary search path 'example/node_modules/@types'.
Found 'package.json' at 'example/node_modules/@types/q/package.json'.
'package.json' does not have a 'typesVersions' field.
'package.json' does not have a 'typings' field.
'package.json' has 'types' field 'index.d.ts' that references 'example/node_modules/@types/q/index.d.ts'.
File 'example/node_modules/@types/q/index.d.ts' exist - use it as a name resolution result.
Resolving real path for 'example/node_modules/@types/q/index.d.ts', result 'example/node_modules/@types/q/index.d.ts'.
======== Type reference directive 'q' was successfully resolved to 'example/node_modules/@types/q/index.d.ts' with Package ID '@types/q/[email protected]', primary: true. ========

@RyanCavanaugh RyanCavanaugh added the Question An issue which isn't directly actionable in code label Feb 18, 2021
@RyanCavanaugh
Copy link
Member

RyanCavanaugh commented Feb 18, 2021

In 4.2+ you can also run tsc --explainFiles

@typescript-bot
Copy link
Collaborator

This issue has been marked as 'Question' and has seen no recent activity. It has been automatically closed for house-keeping purposes. If you're still waiting on a response, questions are usually better suited to stackoverflow.

@roebuk
Copy link
Author

roebuk commented Feb 23, 2021

I've run with tsc --explainFiles and this is my output when pointing to jsconfig.json

node_modules/typescript/lib/lib.d.ts
  Default library
node_modules/typescript/lib/lib.es5.d.ts
  Library referenced via 'es5' from file 'node_modules/typescript/lib/lib.d.ts'
node_modules/typescript/lib/lib.dom.d.ts
  Library referenced via 'dom' from file 'node_modules/typescript/lib/lib.d.ts'
node_modules/typescript/lib/lib.webworker.importscripts.d.ts
  Library referenced via 'webworker.importscripts' from file 'node_modules/typescript/lib/lib.d.ts'
node_modules/typescript/lib/lib.scripthost.d.ts
  Library referenced via 'scripthost' from file 'node_modules/typescript/lib/lib.d.ts'
node_modules/react/cjs/react.production.min.js
  Imported via './cjs/react.production.min.js' from file 'node_modules/react/index.js' with packageId 'react/cjs/[email protected]'
node_modules/react/cjs/react.development.js
  Imported via './cjs/react.development.js' from file 'node_modules/react/index.js' with packageId 'react/cjs/[email protected]'
node_modules/react/index.js
  Imported via 'react' from file 'src/Header.js' with packageId 'react/[email protected]'
  Imported via 'react' from file 'src/index.js' with packageId 'react/[email protected]'
src/Header.js
  Matched by include pattern 'src' in 'jsconfig.json'
node_modules/react-dom/cjs/react-dom.production.min.js
  Imported via './cjs/react-dom.production.min.js' from file 'node_modules/react-dom/index.js' with packageId 'react-dom/cjs/[email protected]'
node_modules/react-dom/cjs/react-dom.development.js
  Imported via './cjs/react-dom.development.js' from file 'node_modules/react-dom/index.js' with packageId 'react-dom/cjs/[email protected]'
node_modules/react-dom/index.js
  Imported via 'react-dom' from file 'src/index.js' with packageId 'react-dom/[email protected]'
src/index.js
  Matched by include pattern 'src' in 'jsconfig.json'
node_modules/@types/q/index.d.ts
  Entry point for implicit type library 'q' with packageId '@types/q/[email protected]'

And this is the output when pointing to a tsconfig.json

node_modules/typescript/lib/lib.d.ts
  Default library
node_modules/typescript/lib/lib.es5.d.ts
  Library referenced via 'es5' from file 'node_modules/typescript/lib/lib.d.ts'
node_modules/typescript/lib/lib.dom.d.ts
  Library referenced via 'dom' from file 'node_modules/typescript/lib/lib.d.ts'
node_modules/typescript/lib/lib.webworker.importscripts.d.ts
  Library referenced via 'webworker.importscripts' from file 'node_modules/typescript/lib/lib.d.ts'
node_modules/typescript/lib/lib.scripthost.d.ts
  Library referenced via 'scripthost' from file 'node_modules/typescript/lib/lib.d.ts'
src/Header.js
  Matched by include pattern 'src' in 'tsconfig.json'
src/index.js
  Matched by include pattern 'src' in 'tsconfig.json'
node_modules/@types/q/index.d.ts
  Entry point for implicit type library 'q' with packageId '@types/q/[email protected]'

@roebuk
Copy link
Author

roebuk commented Feb 23, 2021

Please don't allow bots to auto-close an in-progress ticket.

@RyanCavanaugh

gurdiga added a commit to gurdiga/rss-email-subscription that referenced this issue Jun 13, 2021
I started with jsconfig.json, but I stumbled upon a know issue [1] where
tsc would throw typing errors from node_modules. I could work this
around by adding @types/xml2js, which worked, but made no sense outside
of the context of this tsc issue, so I opted for switching to
tsconfig.json.

[1]: microsoft/TypeScript#42797
@markcellus
Copy link

This issue is closed but is still happening, even when the project has only a jsconfig.json file. I've refiled in #50862.

@Ciantic
Copy link

Ciantic commented Sep 14, 2023

This is a first result when searching, the solution is this:

You're seeing this weird behavior because jsconfig.json sets the maxNodeModuleJsDepth option to 2 (tsconfig.json default is 0).

Downside is that type inference doesn't work as well if you chuck that to jsconfig.json

It's explained in the #50862 better, but solution is simply: add property to jsconfig.json

{
  "compilerOptions": {
    "checkJs": true,
    "strict": true,
    "module": "CommonJS",
    "resolveJsonModule": true,
    "maxNodeModuleJsDepth": 0 // <--- ADD THIS
  },

Another solution is to call typechecking your project files like this:

tsc -p jsconfig.json --maxNodeModuleJsDepth 0

This way you can have maxNodeModuleJsDepth default to 2 in jsconfig projects, but check only your files from command line.

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

6 participants