-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
typeRoots does not exсlude typings in node_modules #15933
Comments
TypeRoots is only used for global files, but not for modules. modules follow the normal resolution path. So in addition to TypeRoots, you will need to add a path mapping as well: "baseUrl": "./",
"paths" : {
"*" : ["src/typings/*"]
} |
Frankly speaking I can't understand why such different behaviors are needed. In the provided example adding path mapping helps. Bit it breaks again as soon as I add
Doesn't work:
error:
|
typeRoots is meant to include global definitions into your code, e.g. Modules however have a different semantics; they have their own scope, and two versions can co-exist, and the compiler supports that. It is perfectly legal for you to have a dependency on Please see #11137 (comment) for more details.
yes, and there is
set |
It helps in this simplest example. But in my project it (setting
then TS fails to find it with in
with |
I am sorry, i am not sure i follow the example.. how is how does "moduleResolution: classic" fix that for you? |
It's not. It's non-relative. That's because TS in "moduleResolution: node" looks in node_modules folders. Here's log from running
|
and why wouldn't the same work for |
Here's a run but with "moduleResolution: node":
tsconfig:
|
Let me put some summary at the point. Initial approach to specify I reverted back moduleResolution to Classic to tried to understand why it doesn't work. Why output module format does effect probing for typing during compile-time? Some details:
works fine.
Doen't work:
P.S. #11329 is a similar question |
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed. |
TypeScript Version: 2.1.5, 2.3.2
Use case:
Given a project:
tsconfig.json
is:node_modules
contains@types\jquery
package (installed asnpm i @types/jquery
.src/typings
folder contains the folderjquery
same asnode_modules/@types/jquery
(just copied from there).Expected behavior:
It just works. TS should use typings from
src/typings
folder as it's specified intypeRoots
option in tsconfig. Typings innode_modules
should be ignored.Actual behavior:
TS uses .d.ts from
node_modules
! So they can (and did) conflict with typings in custom typeRoots.The text was updated successfully, but these errors were encountered: