Repository navigation
typeRoots does not exсlude typings in node_modules #15933
Description
Activity
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/*"] }
Reacted by Anton Shevel- addedQuestionAn issue which isn't directly actionable in codeAn issue which isn't directly actionable in code
on May 18, 2017 Frankly speaking I can't understand why such different behaviors are needed.
It looks useful to be able to override where to search for typings in case ofimport "module"as well. Anyway it's totally unclear why "exclude: ['node_modules']" doesn't work.In the provided example adding path mapping helps. Bit it breaks again as soon as I add
module: 'amd'.
Works:{ "compilerOptions": { // "module": "amd", "baseUrl": "./", "paths" : { "lib/*": [ "src/lib/*" ], "*" : ["src/typings/*"] }, "typeRoots" : ["src/typings"] }, "include": ["src/**/*.ts"] }Doesn't work:
{ "compilerOptions": { "module": "amd", "baseUrl": "./", "paths" : { "lib/*": [ "src/lib/*" ], "*" : ["src/typings/*"] }, "typeRoots" : ["src/typings"] }, "include": [ "src/**/*.ts" ] }error:
node_modules/@types/jquery/index.d.ts(3786,5): error TS2300: Duplicate identifier 'export='. src/typings/jquery/index.d.ts(745,5): error TS2374: Duplicate string index signature. src/typings/jquery/index.d.ts(3339,5): error TS2375: Duplicate number index signature. src/typings/jquery/index.d.ts(3767,5): error TS2300: Duplicate identifier 'export='.Frankly speaking I can't understand why such different behaviors are needed.
typeRoots is meant to include global definitions into your code, e.g.
node\index.d.ts,elctorn\index.d.ts, mocha env, etc.. in these scenarios you want to be able to override the definition and say, no I am going to inject a specific version of these global. The issue here is you can not have two versions of a global..
Most declarations are not global in nature, so you should not need to use--typeRootsoften.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
PackageA@2.0at the same time as one of your dependencies have a dependency onPackageA@1.0. the resolution of these modules have to follow the run time resolution logic, that node will do for instance.Please see #11137 (comment) for more details.
It looks useful to be able to override where to search for typings in case of import "module" as well. Anyway
yes, and there is
pathsto support just that. please find more details at: http://www.typescriptlang.org/docs/handbook/module-resolution.html#path-mappingit's totally unclear why "exclude: ['node_modules']" doesn't work.
In the provided example adding path mapping helps. Bit it breaks again as soon as I add module: 'amd'.
Works:set
"moduleResolution": "node"In the provided example adding path mapping helps. Bit it breaks again as soon as I add
module: 'amd'.set
"moduleResolution": "node"It helps in this simplest example. But in my project it (setting
moduleResolution=node) produces lots of errors.
If a module imports a non-relative module somewhere :import { IDataFacade } from "interop/.interop";then TS fails to find it with in
moduleResolution=nodemode with the mentioned tsconfig (two paths "" and "lib/").
It's understandable as it's not relative module name and TS looks in node_modules folder hierarchy.
You may say "make these imports relative". But (beside that it'll requires some work) it doesn't work in some cases. For example:
given an ambient module (core.all.d.ts):declare module "core.ui" { export * from "ui/.ui"; }with
moduleResolution=nodeTS can't see "ui/.ui" (uifolder is at the same level ascore.all.d.tsfile). But if I try to change "ui/.ui" to "./ui/.ui" I'll get TS2439:Import or export declaration in an ambient module declaration cannot reference module through relative module name.I am sorry, i am not sure i follow the example.. how is
"ui/.ui"a relative name? relative to what?how does "moduleResolution: classic" fix that for you?
how is "ui/.ui" a relative name? relative to what?
It's not. It's non-relative. That's because TS in "moduleResolution: node" looks in node_modules folders.
But in "moduleResolution: classic" TS can finds it.Here's log from running
tsc --traceResolution:======== Resolving module 'lib/ui/.ui' from 'D:/Work/R-n-D/XFW3_WebClient/Client/src/lib/.core.d.ts'. ======== Module resolution kind is not specified, using 'Classic'. 'baseUrl' option is set to 'D:/Work/R-n-D/XFW3_WebClient/Client', using this value to resolve non-relative module name 'lib/ui/.ui' 'paths' option is specified, looking for a pattern to match module name 'lib/ui/.ui'. Module name 'lib/ui/.ui', matched pattern 'lib/*'. Trying substitution 'src/lib/*', candidate module location: 'src/lib/ui/.ui'. File 'D:/Work/R-n-D/XFW3_WebClient/Client/src/lib/ui/.ui.ts' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/Client/src/lib/ui/.ui.tsx' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/Client/src/lib/ui/.ui.d.ts' exist - use it as a name resolution result. ======== Module name 'lib/ui/.ui' was successfully resolved to 'D:/Work/R-n-D/XFW3_WebClient/Client/src/lib/ui/.ui.d.ts'. ========and why wouldn't the same work for
"moduleResolution: node"?Here's a run but with "moduleResolution: node":
======== Resolving module 'ui/.ui' from 'D:/Work/R-n-D/XFW3_WebClient/Client/src/lib/core.all.d.ts'. ======== Explicitly specified module resolution kind: 'NodeJs'. 'baseUrl' option is set to 'D:/Work/R-n-D/XFW3_WebClient/Client', using this value to resolve non-relative module name 'ui/.ui' 'paths' option is specified, looking for a pattern to match module name 'ui/.ui'. Module name 'ui/.ui', matched pattern '*'. Trying substitution 'src/typings/*', candidate module location: 'src/typings/ui/.ui'. Loading module as file / folder, candidate module location 'D:/Work/R-n-D/XFW3_WebClient/Client/src/typings/ui/.ui'. File 'D:/Work/R-n-D/XFW3_WebClient/Client/src/typings/ui/.ui.ts' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/Client/src/typings/ui/.ui.tsx' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/Client/src/typings/ui/.ui.d.ts' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/Client/src/typings/ui/.ui/package.json' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/Client/src/typings/ui/.ui/index.ts' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/Client/src/typings/ui/.ui/index.tsx' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/Client/src/typings/ui/.ui/index.d.ts' does not exist. Loading module 'ui/.ui' from 'node_modules' folder. File 'D:/Work/R-n-D/XFW3_WebClient/Client/src/lib/node_modules/ui/.ui.ts' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/Client/src/lib/node_modules/ui/.ui.tsx' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/Client/src/lib/node_modules/ui/.ui.d.ts' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/Client/src/lib/node_modules/ui/.ui/package.json' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/Client/src/lib/node_modules/ui/.ui/index.ts' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/Client/src/lib/node_modules/ui/.ui/index.tsx' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/Client/src/lib/node_modules/ui/.ui/index.d.ts' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/Client/src/lib/node_modules/@types/ui/.ui.d.ts' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/Client/src/lib/node_modules/@types/ui/.ui/package.json' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/Client/src/lib/node_modules/@types/ui/.ui/index.d.ts' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/Client/src/node_modules/ui/.ui.ts' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/Client/src/node_modules/ui/.ui.tsx' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/Client/src/node_modules/ui/.ui.d.ts' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/Client/src/node_modules/ui/.ui/package.json' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/Client/src/node_modules/ui/.ui/index.ts' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/Client/src/node_modules/ui/.ui/index.tsx' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/Client/src/node_modules/ui/.ui/index.d.ts' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/Client/src/node_modules/@types/ui/.ui.d.ts' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/Client/src/node_modules/@types/ui/.ui/package.json' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/Client/src/node_modules/@types/ui/.ui/index.d.ts' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/Client/node_modules/ui/.ui.ts' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/Client/node_modules/ui/.ui.tsx' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/Client/node_modules/ui/.ui.d.ts' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/Client/node_modules/ui/.ui/package.json' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/Client/node_modules/ui/.ui/index.ts' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/Client/node_modules/ui/.ui/index.tsx' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/Client/node_modules/ui/.ui/index.d.ts' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/Client/node_modules/@types/ui/.ui.d.ts' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/Client/node_modules/@types/ui/.ui/package.json' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/Client/node_modules/@types/ui/.ui/index.d.ts' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/node_modules/ui/.ui.ts' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/node_modules/ui/.ui.tsx' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/node_modules/ui/.ui.d.ts' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/node_modules/ui/.ui/package.json' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/node_modules/ui/.ui/index.ts' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/node_modules/ui/.ui/index.tsx' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/node_modules/ui/.ui/index.d.ts' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/node_modules/@types/ui/.ui.d.ts' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/node_modules/@types/ui/.ui/package.json' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/node_modules/@types/ui/.ui/index.d.ts' does not exist. File 'D:/Work/R-n-D/node_modules/ui/.ui.ts' does not exist. File 'D:/Work/R-n-D/node_modules/ui/.ui.tsx' does not exist. File 'D:/Work/R-n-D/node_modules/ui/.ui.d.ts' does not exist. File 'D:/Work/R-n-D/node_modules/ui/.ui/package.json' does not exist. File 'D:/Work/R-n-D/node_modules/ui/.ui/index.ts' does not exist. File 'D:/Work/R-n-D/node_modules/ui/.ui/index.tsx' does not exist. File 'D:/Work/R-n-D/node_modules/ui/.ui/index.d.ts' does not exist. File 'D:/Work/R-n-D/node_modules/@types/ui/.ui.d.ts' does not exist. File 'D:/Work/R-n-D/node_modules/@types/ui/.ui/package.json' does not exist. File 'D:/Work/R-n-D/node_modules/@types/ui/.ui/index.d.ts' does not exist. File 'D:/Work/node_modules/ui/.ui.ts' does not exist. File 'D:/Work/node_modules/ui/.ui.tsx' does not exist. File 'D:/Work/node_modules/ui/.ui.d.ts' does not exist. File 'D:/Work/node_modules/ui/.ui/package.json' does not exist. File 'D:/Work/node_modules/ui/.ui/index.ts' does not exist. File 'D:/Work/node_modules/ui/.ui/index.tsx' does not exist. File 'D:/Work/node_modules/ui/.ui/index.d.ts' does not exist. File 'D:/Work/node_modules/@types/ui/.ui.d.ts' does not exist. File 'D:/Work/node_modules/@types/ui/.ui/package.json' does not exist. File 'D:/Work/node_modules/@types/ui/.ui/index.d.ts' does not exist. File 'D:/node_modules/ui/.ui.ts' does not exist. File 'D:/node_modules/ui/.ui.tsx' does not exist. File 'D:/node_modules/ui/.ui.d.ts' does not exist. File 'D:/node_modules/ui/.ui/package.json' does not exist. File 'D:/node_modules/ui/.ui/index.ts' does not exist. File 'D:/node_modules/ui/.ui/index.tsx' does not exist. File 'D:/node_modules/ui/.ui/index.d.ts' does not exist. File 'D:/node_modules/@types/ui/.ui.d.ts' does not exist. File 'D:/node_modules/@types/ui/.ui/package.json' does not exist. File 'D:/node_modules/@types/ui/.ui/index.d.ts' does not exist. 'baseUrl' option is set to 'D:/Work/R-n-D/XFW3_WebClient/Client', using this value to resolve non-relative module name 'ui/.ui' 'paths' option is specified, looking for a pattern to match module name 'ui/.ui'. Module name 'ui/.ui', matched pattern '*'. Trying substitution 'src/typings/*', candidate module location: 'src/typings/ui/.ui'. Loading module as file / folder, candidate module location 'D:/Work/R-n-D/XFW3_WebClient/Client/src/typings/ui/.ui'. File 'D:/Work/R-n-D/XFW3_WebClient/Client/src/typings/ui/.ui.js' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/Client/src/typings/ui/.ui.jsx' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/Client/src/typings/ui/.ui/package.json' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/Client/src/typings/ui/.ui/index.js' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/Client/src/typings/ui/.ui/index.jsx' does not exist. Loading module 'ui/.ui' from 'node_modules' folder. File 'D:/Work/R-n-D/XFW3_WebClient/Client/src/lib/node_modules/ui/.ui.js' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/Client/src/lib/node_modules/ui/.ui.jsx' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/Client/src/lib/node_modules/ui/.ui/package.json' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/Client/src/lib/node_modules/ui/.ui/index.js' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/Client/src/lib/node_modules/ui/.ui/index.jsx' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/Client/src/node_modules/ui/.ui.js' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/Client/src/node_modules/ui/.ui.jsx' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/Client/src/node_modules/ui/.ui/package.json' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/Client/src/node_modules/ui/.ui/index.js' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/Client/src/node_modules/ui/.ui/index.jsx' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/Client/node_modules/ui/.ui.js' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/Client/node_modules/ui/.ui.jsx' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/Client/node_modules/ui/.ui/package.json' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/Client/node_modules/ui/.ui/index.js' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/Client/node_modules/ui/.ui/index.jsx' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/node_modules/ui/.ui.js' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/node_modules/ui/.ui.jsx' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/node_modules/ui/.ui/package.json' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/node_modules/ui/.ui/index.js' does not exist. File 'D:/Work/R-n-D/XFW3_WebClient/node_modules/ui/.ui/index.jsx' does not exist. File 'D:/Work/R-n-D/node_modules/ui/.ui.js' does not exist. File 'D:/Work/R-n-D/node_modules/ui/.ui.jsx' does not exist. File 'D:/Work/R-n-D/node_modules/ui/.ui/package.json' does not exist. File 'D:/Work/R-n-D/node_modules/ui/.ui/index.js' does not exist. File 'D:/Work/R-n-D/node_modules/ui/.ui/index.jsx' does not exist. File 'D:/Work/node_modules/ui/.ui.js' does not exist. File 'D:/Work/node_modules/ui/.ui.jsx' does not exist. File 'D:/Work/node_modules/ui/.ui/package.json' does not exist. File 'D:/Work/node_modules/ui/.ui/index.js' does not exist. File 'D:/Work/node_modules/ui/.ui/index.jsx' does not exist. File 'D:/node_modules/ui/.ui.js' does not exist. File 'D:/node_modules/ui/.ui.jsx' does not exist. File 'D:/node_modules/ui/.ui/package.json' does not exist. File 'D:/node_modules/ui/.ui/index.js' does not exist. File 'D:/node_modules/ui/.ui/index.jsx' does not exist. ======== Module name 'ui/.ui' was not resolved. ========tsconfig:
"paths": { // map runtime paths to compile-time paths "lib/*": [ "src/lib/*" ], "modules/*": [ "src/modules/*" ], "vendor/*": [ "src/vendor/*" ], "*" : ["src/typings/*"] },Let me put some summary at the point.
I want a library to have a folder with custom typings (not from npm@typingpackage). At the same time@typingpackage can exist in node_modules. And it shouldn't interfere with using custom typings.Initial approach to specify
typeRootswas not correct astypeRootsis not designed for modules.
An approach for custom typing for modules is using path mappings - so you suggested adding"*" : ["src/typings/*"]into tsconfig'spaths.
But it breaks in case of using"module": "amd".
Then you suggested setting"moduleResolution": "node". But in my project it breaks because of imports of non-relative modules in ambient context which paths are related topathsin tsconfig (sound complex agree). But I think we could agree that"moduleResolution": "node"could not be applicable in some cases for any reason (?).I reverted back moduleResolution to Classic to tried to understand why it doesn't work.
I found that if I putjquery.d.tsinsidetypingsfolder ("/typings/jquery.d.ts" instead of "typings/jquery/index.d.ts") then it works fine.
So this means that typing from https://github.com/DefinitelyTyped/DefinitelyTyped/ repo isn't suitable for using with moduleResolution=Classic and module=amd. Which is weird.Why output module format does effect probing for typing during compile-time?
Some details:
- compile without
module: "amd", with npm package@typing/jqueryinside "src/typings" folder ("src/typing/jquery/index.d.ts")
{ "compilerOptions": { "baseUrl": "./", "paths" : { "lib/*": [ "src/lib/*" ], "*" : ["src/typings/*"] }, "typeRoots" : ["src/typings"] }, "include": ["src/**/*.ts"] }works fine.
output:======== Resolving module 'jquery' from 'D:/Work/Learn/typescript/inherit-typings-bug/lib/src/lib/lib.ts'. ======== Module resolution kind is not specified, using 'NodeJs'. 'baseUrl' option is set to 'D:/Work/Learn/typescript/inherit-typings-bug/lib/', using this value to resolve non-relative module name 'jquery' 'paths' option is specified, looking for a pattern to match module name 'jquery'. Module name 'jquery', matched pattern '*'. Trying substitution 'src/typings/*', candidate module location: 'src/typings/jquery'. Loading module as file / folder, candidate module location 'D:/Work/Learn/typescript/inherit-typings-bug/lib/src/typings/jquery'. File 'D:/Work/Learn/typescript/inherit-typings-bug/lib/src/typings/jquery.ts' does not exist. File 'D:/Work/Learn/typescript/inherit-typings-bug/lib/src/typings/jquery.tsx' does not exist. File 'D:/Work/Learn/typescript/inherit-typings-bug/lib/src/typings/jquery.d.ts' does not exist. Found 'package.json' at 'D:/Work/Learn/typescript/inherit-typings-bug/lib/src/typings/jquery/package.json'. 'package.json' does not have a 'types' or 'main' field. File 'D:/Work/Learn/typescript/inherit-typings-bug/lib/src/typings/jquery/index.ts' does not exist. File 'D:/Work/Learn/typescript/inherit-typings-bug/lib/src/typings/jquery/index.tsx' does not exist. File 'D:/Work/Learn/typescript/inherit-typings-bug/lib/src/typings/jquery/index.d.ts' exist - use it as a name resolution result. ======== Module name 'jquery' was successfully resolved to 'D:/Work/Learn/typescript/inherit-typings-bug/lib/src/typings/jquery/index.d.ts'. ======== ======== Resolving type reference directive 'jquery', containing file 'D:/Work/Learn/typescript/inherit-typings-bug/lib/__inferred type names__.ts', root directory 'D:/Work/Learn/typescript/inherit-typings-bug/lib/src/typings'. ======== Resolving with primary search path 'D:/Work/Learn/typescript/inherit-typings-bug/lib/src/typings' Found 'package.json' at 'D:/Work/Learn/typescript/inherit-typings-bug/lib/src/typings/jquery/package.json'. 'package.json' does not have a 'types' or 'main' field. File 'D:/Work/Learn/typescript/inherit-typings-bug/lib/src/typings/jquery/index.d.ts' exist - use it as a name resolution result. Resolving real path for 'D:/Work/Learn/typescript/inherit-typings-bug/lib/src/typings/jquery/index.d.ts', result 'D:/Work/Learn/typescript/inherit-typings-bug/lib/src/typings/jquery/index.d.ts' ======== Type reference directive 'jquery' was successfully resolved to 'D:/Work/Learn/typescript/inherit-typings-bug/lib/src/typings/jquery/index.d.ts', primary: true. ========- compile with
module: "amd", with npm package@typing/jqueryinside "src/typings" folder ("src/typing/jquery/index.d.ts")
{ "compilerOptions": { "baseUrl": "./", "paths" : { "lib/*": [ "src/lib/*" ], "*" : ["src/typings/*"] }, "typeRoots" : ["src/typings"] }, "include": ["src/**/*.ts"] }Doen't work:
node_modules/@types/jquery/index.d.ts(3786,5): error TS2300: Duplicate identifier 'export='.
Output:======== Resolving module 'jquery' from 'D:/Work/Learn/typescript/inherit-typings-bug/lib/src/lib/lib.ts'. ======== Module resolution kind is not specified, using 'Classic'. 'baseUrl' option is set to 'D:/Work/Learn/typescript/inherit-typings-bug/lib/', using this value to resolve non-relative module name 'jquery' 'paths' option is specified, looking for a pattern to match module name 'jquery'. Module name 'jquery', matched pattern '*'. Trying substitution 'src/typings/*', candidate module location: 'src/typings/jquery'. File 'D:/Work/Learn/typescript/inherit-typings-bug/lib/src/typings/jquery.ts' does not exist. File 'D:/Work/Learn/typescript/inherit-typings-bug/lib/src/typings/jquery.tsx' does not exist. File 'D:/Work/Learn/typescript/inherit-typings-bug/lib/src/typings/jquery.d.ts' does not exist. File 'D:/Work/Learn/typescript/inherit-typings-bug/lib/src/lib/jquery.ts' does not exist. File 'D:/Work/Learn/typescript/inherit-typings-bug/lib/src/lib/jquery.tsx' does not exist. File 'D:/Work/Learn/typescript/inherit-typings-bug/lib/src/lib/jquery.d.ts' does not exist. File 'D:/Work/Learn/typescript/inherit-typings-bug/lib/src/jquery.ts' does not exist. File 'D:/Work/Learn/typescript/inherit-typings-bug/lib/src/jquery.tsx' does not exist. File 'D:/Work/Learn/typescript/inherit-typings-bug/lib/src/jquery.d.ts' does not exist. File 'D:/Work/Learn/typescript/inherit-typings-bug/lib/jquery.ts' does not exist. File 'D:/Work/Learn/typescript/inherit-typings-bug/lib/jquery.tsx' does not exist. File 'D:/Work/Learn/typescript/inherit-typings-bug/lib/jquery.d.ts' does not exist. File 'D:/Work/Learn/typescript/inherit-typings-bug/jquery.ts' does not exist. File 'D:/Work/Learn/typescript/inherit-typings-bug/jquery.tsx' does not exist. File 'D:/Work/Learn/typescript/inherit-typings-bug/jquery.d.ts' does not exist. File 'D:/Work/Learn/typescript/jquery.ts' does not exist. File 'D:/Work/Learn/typescript/jquery.tsx' does not exist. File 'D:/Work/Learn/typescript/jquery.d.ts' does not exist. File 'D:/Work/Learn/jquery.ts' does not exist. File 'D:/Work/Learn/jquery.tsx' does not exist. File 'D:/Work/Learn/jquery.d.ts' does not exist. File 'D:/Work/jquery.ts' does not exist. File 'D:/Work/jquery.tsx' does not exist. File 'D:/Work/jquery.d.ts' does not exist. File 'D:/jquery.ts' does not exist. File 'D:/jquery.tsx' does not exist. File 'D:/jquery.d.ts' does not exist. File 'D:/Work/Learn/typescript/inherit-typings-bug/lib/src/lib/node_modules/@types/jquery.d.ts' does not exist. File 'D:/Work/Learn/typescript/inherit-typings-bug/lib/src/lib/node_modules/@types/jquery/package.json' does not exist. File 'D:/Work/Learn/typescript/inherit-typings-bug/lib/src/lib/node_modules/@types/jquery/index.d.ts' does not exist. File 'D:/Work/Learn/typescript/inherit-typings-bug/lib/src/node_modules/@types/jquery.d.ts' does not exist. File 'D:/Work/Learn/typescript/inherit-typings-bug/lib/src/node_modules/@types/jquery/package.json' does not exist. File 'D:/Work/Learn/typescript/inherit-typings-bug/lib/src/node_modules/@types/jquery/index.d.ts' does not exist. File 'D:/Work/Learn/typescript/inherit-typings-bug/lib/node_modules/@types/jquery.d.ts' does not exist. Found 'package.json' at 'D:/Work/Learn/typescript/inherit-typings-bug/lib/node_modules/@types/jquery/package.json'. 'package.json' does not have a 'types' or 'main' field. File 'D:/Work/Learn/typescript/inherit-typings-bug/lib/node_modules/@types/jquery/index.d.ts' exist - use it as a name resolution result. ======== Module name 'jquery' was successfully resolved to 'D:/Work/Learn/typescript/inherit-typings-bug/lib/node_modules/@types/jquery/index.d.ts'. ======== ======== Resolving type reference directive 'jquery', containing file 'D:/Work/Learn/typescript/inherit-typings-bug/lib/__inferred type names__.ts', root directory 'D:/Work/Learn/typescript/inherit-typings-bug/lib/src/typings'. ======== Resolving with primary search path 'D:/Work/Learn/typescript/inherit-typings-bug/lib/src/typings' Found 'package.json' at 'D:/Work/Learn/typescript/inherit-typings-bug/lib/src/typings/jquery/package.json'. 'package.json' does not have a 'types' or 'main' field. File 'D:/Work/Learn/typescript/inherit-typings-bug/lib/src/typings/jquery/index.d.ts' exist - use it as a name resolution result. Resolving real path for 'D:/Work/Learn/typescript/inherit-typings-bug/lib/src/typings/jquery/index.d.ts', result 'D:/Work/Learn/typescript/inherit-typings-bug/lib/src/typings/jquery/index.d.ts' ======== Type reference directive 'jquery' was successfully resolved to 'D:/Work/Learn/typescript/inherit-typings-bug/lib/src/typings/jquery/index.d.ts', primary: true. ========P.S. #11329 is a similar question
- compile without
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.
- locked and limited conversation to collaborators
on Jun 14, 2018
TypeScript Version: 2.1.5, 2.3.2
Use case:
Given a project:
tsconfig.jsonis:node_modulescontains@types\jquerypackage (installed asnpm i @types/jquery.src/typingsfolder contains the folderjquerysame asnode_modules/@types/jquery(just copied from there).Expected behavior:
It just works. TS should use typings from
src/typingsfolder as it's specified intypeRootsoption in tsconfig. Typings innode_modulesshould be ignored.Actual behavior:
TS uses .d.ts from
node_modules! So they can (and did) conflict with typings in custom typeRoots.