Skip to content

typeRoots does not exсlude typings in node_modules #15933

Description

TypeScript Version: 2.1.5, 2.3.2

Use case:
Given a project:

node_modules/
src/
package.json
tsconfig.json

tsconfig.json is:

{
	"compilerOptions": {
		"typeRoots" : ["src/typings"]
	},
	"include": [
		"src/**/*.ts"
	],
	"exclude": [
		"node_modules"
	]
}

node_modules contains @types\jquery package (installed as npm i @types/jquery.
src/typings folder contains the folder jquery same as node_modules/@types/jquery (just copied from there).

Expected behavior:
It just works. TS should use typings from src/typings folder as it's specified in typeRoots option in tsconfig. Typings in node_modules should be ignored.

Actual behavior:
TS uses .d.ts from node_modules! So they can (and did) conflict with typings in custom typeRoots.

D:\Work\Learn\typescript\inherit-typings-bug\lib>tsc
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='.

Activity

  1. mhegazy commented on May 18, 2017

    @mhegazy
    Contributor

    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/*"]
    }
  2. evil-shrike commented on May 19, 2017

    @evil-shrike
    Author

    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 of import "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='.
    
  3. mhegazy commented on May 19, 2017

    @mhegazy
    Contributor

    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 --typeRoots often.

    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.0 at the same time as one of your dependencies have a dependency on PackageA@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 paths to support just that. please find more details at: http://www.typescriptlang.org/docs/handbook/module-resolution.html#path-mapping

    it's totally unclear why "exclude: ['node_modules']" doesn't work.

    Please see https://github.com/Microsoft/TypeScript/wiki/FAQ#why-is-a-file-in-the-exclude-list-still-picked-up-by-the-compiler

    In the provided example adding path mapping helps. Bit it breaks again as soon as I add module: 'amd'.
    Works:

    set "moduleResolution": "node"

  4. evil-shrike commented on May 22, 2017

    @evil-shrike
    Author

    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=node mode 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=node TS can't see "ui/.ui" (ui folder is at the same level as core.all.d.ts file). 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.

  5. mhegazy commented on May 22, 2017

    @mhegazy
    Contributor

    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?

  6. evil-shrike commented on May 22, 2017

    @evil-shrike
    Author

    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'. ========
    
  7. mhegazy commented on May 22, 2017

    @mhegazy
    Contributor

    and why wouldn't the same work for "moduleResolution: node"?

  8. evil-shrike commented on May 23, 2017

    @evil-shrike
    Author

    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/*"]
    		},
    
  9. evil-shrike commented on May 24, 2017

    @evil-shrike
    Author

    Let me put some summary at the point.
    I want a library to have a folder with custom typings (not from npm @typing package). At the same time @typing package can exist in node_modules. And it shouldn't interfere with using custom typings.

    Initial approach to specify typeRoots was not correct as typeRoots is not designed for modules.
    An approach for custom typing for modules is using path mappings - so you suggested adding "*" : ["src/typings/*"] into tsconfig's paths.
    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 to paths in 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 put jquery.d.ts inside typings folder ("/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:

    1. compile without module: "amd", with npm package @typing/jquery inside "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. ========
    
    1. compile with module: "amd", with npm package @typing/jquery inside "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

  10. mhegazy commented on Jun 7, 2017

    @mhegazy
    Contributor

    Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.

  11. locked and limited conversation to collaborators on Jun 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionAn issue which isn't directly actionable in code

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions