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

tsc with --allowJS ignores modules in node_modules #17182

Closed
speigg opened this issue Jul 14, 2017 · 2 comments
Closed

tsc with --allowJS ignores modules in node_modules #17182

speigg opened this issue Jul 14, 2017 · 2 comments

Comments

@speigg
Copy link

speigg commented Jul 14, 2017

TypeScript Version: 2.4.1

Code

// A *self-contained* demonstration of the problem follows...
import module = require('module-in-node_modules-with-jsdoc-annotations');

Compiling with commonjs module resolution, and the --allowJS and --checkJS compiler options.

Expected behavior:

  1. Typescript should be able to "find" any modules that are installed (e.g. in "node_modules"), even if it doesn't have type definitions for them.
  2. Typescript should be able to rely on jsdoc annotations within those modules for type checking and language services.

Actual behavior:

[ts] Cannot find module 'module-in-node_modules-with-jsdoc-annotations'.

@speigg speigg changed the title checkJS ignores jsdoc for modules from node_modules tsk with --checkJS ignores modules in node_modules Jul 14, 2017
@speigg speigg changed the title tsk with --checkJS ignores modules in node_modules tsc with --checkJS ignores modules in node_modules Jul 14, 2017
@speigg
Copy link
Author

speigg commented Jul 14, 2017

I just discovered the maxNodeModuleJsDepth compiler option!

It seems that the default for maxNodeModuleJsDepth is 0?

Setting it to 1 (or greater, obviously) fixes the problem. (Also, it seems I don't need to use the --checkJS to make this work after all).

Anyway, it would be nice if the maxNodeModuleJsDepth were set to 1 by default, so that only the --allowJS is needed for top-level node modules. Closing since I found a solution though.

@speigg speigg closed this as completed Jul 14, 2017
@speigg speigg changed the title tsc with --checkJS ignores modules in node_modules tsc with --allowJS ignores modules in node_modules Jul 14, 2017
@speigg
Copy link
Author

speigg commented Jul 14, 2017

For reference, looks like maxNodeModuleJsDepth originally defaulted to 2, but this was changed to 0 for performance reasons in #10538

@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant