-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Closed
Labels
DuplicateAn existing issue was already createdAn existing issue was already created
Description
I want to try to use @types like repository.
TypeScript Version: Version 2.2.0-dev.20161114
Code
$ tree
tree
.
├── package.json
├── src
│ └── index.ts
├── tsconfig.json
└── typings
└── foo
└── index.d.ts
$ cat tsconfig.json
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"typeRoots": [
"./typings"
],
"types": [
"foo"
],
"noImplicitAny": false,
"sourceMap": false
},
"include": [
"src/**/*.ts"
]
}
$ cat typings/foo/index.d.ts
export function hi(): void;
$ cat src/index.ts
import * as _ from "foo";
$ tsc -p ./tsconfig.json --traceResolution
======== Resolving module 'foo' from '/***/work/src/index.ts'. ========
Module resolution kind is not specified, using 'NodeJs'.
Loading module 'foo' from 'node_modules' folder.
File '/***/word/src/node_modules/foo.ts' does not exist.
...omit...
File '/node_modules/foo/index.jsx' does not exist.
======== Module name 'foo' was not resolved. ========
======== Resolving type reference directive 'foo', containing file '/***/work/__inferred type names__.ts', root directory '/***/work/typings'. ========
Resolving with primary search path '/***/work/typings'
File '/***/work/typings/foo/package.json' does not exist.
File '/***/work/typings/foo/index.d.ts' exist - use it as a name resolution result.
Resolving real path for '/***/work/typings/foo/index.d.ts', result '/***/work/typings/foo/index.d.ts'
======== Type reference directive 'foo' was successfully resolved to '/***/work/typings/foo/index.d.ts', primary: true. ========
src/index.ts(1,20): error TS2307: Cannot find module 'foo'.
tsc can find typings/foo/index.d.ts , but compile was failed...
Expected behavior:
compile successful.
I expect "typeRoots": [] and "typeRoots: ["./node_modules/@types/"]" are equivalent.
I hope I want to use "typeRoots: ["./node_modules/@types/", "./typings/"]"
Actual behavior:
compile failure.
Metadata
Metadata
Assignees
Labels
DuplicateAn existing issue was already createdAn existing issue was already created