diff --git a/src/compiler/program.ts b/src/compiler/program.ts index ba21461e2a0..5ada898acb6 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -1019,6 +1019,8 @@ namespace ts { const filesByNameIgnoreCase = host.useCaseSensitiveFileNames() ? createFileMap(fileName => fileName.toLowerCase()) : undefined; if (!tryReuseStructureFromOldProgram()) { + forEach(rootNames, name => processRootFile(name, /*isDefaultLib*/ false)); + // load type declarations specified via 'types' argument let typeReferences: string[]; if (options.types) { @@ -1027,7 +1029,10 @@ namespace ts { else { // or load all types from the automatic type import fields if (host.getDefaultTypeDirectiveNames) { - typeReferences = host.getDefaultTypeDirectiveNames(getCommonSourceDirectory()); + const commonRoot = getCommonSourceDirectory(); + if (commonRoot) { + typeReferences = host.getDefaultTypeDirectiveNames(commonRoot); + } } } @@ -1038,7 +1043,6 @@ namespace ts { } } - forEach(rootNames, name => processRootFile(name, /*isDefaultLib*/ false)); // Do not process the default library if: // - The '--noLib' flag is used. // - A 'no-default-lib' reference comment is encountered in diff --git a/tests/baselines/reference/jsFileCompilationExternalPackageError.errors.txt b/tests/baselines/reference/jsFileCompilationExternalPackageError.errors.txt deleted file mode 100644 index 58111c777f1..00000000000 --- a/tests/baselines/reference/jsFileCompilationExternalPackageError.errors.txt +++ /dev/null @@ -1,19 +0,0 @@ -tests/cases/compiler/moduleA/a.js(2,17): error TS2656: Exported external package typings file 'tests/cases/compiler/node_modules/b.ts' is not a module. Please contact the package author to update the package definition. - - -==== tests/cases/compiler/moduleA/a.js (1 errors) ==== - - import {a} from "b"; - ~~~ -!!! error TS2656: Exported external package typings file 'b.ts' is not a module. Please contact the package author to update the package definition. - a++; - import {c} from "c"; - c++; - -==== tests/cases/compiler/node_modules/b.ts (0 errors) ==== - var a = 10; - -==== tests/cases/compiler/node_modules/c.js (0 errors) ==== - exports.a = 10; - c = 10; - \ No newline at end of file diff --git a/tests/baselines/reference/jsFileCompilationExternalPackageError.symbols b/tests/baselines/reference/jsFileCompilationExternalPackageError.symbols new file mode 100644 index 00000000000..fcb678c3e6c --- /dev/null +++ b/tests/baselines/reference/jsFileCompilationExternalPackageError.symbols @@ -0,0 +1,25 @@ +=== tests/cases/compiler/moduleA/a.js === + +import {a} from "b"; +>a : Symbol(a, Decl(a.js, 1, 8)) + +a++; +>a : Symbol(a, Decl(a.js, 1, 8)) + +import {c} from "c"; +>c : Symbol(c, Decl(a.js, 3, 8)) + +c++; +>c : Symbol(c, Decl(a.js, 3, 8)) + +=== tests/cases/compiler/node_modules/b.ts === +var a = 10; +>a : Symbol(a, Decl(b.ts, 0, 3)) + +=== tests/cases/compiler/node_modules/c.js === +exports.a = 10; +>exports : Symbol(a, Decl(c.js, 0, 0)) +>a : Symbol(a, Decl(c.js, 0, 0)) + +c = 10; + diff --git a/tests/baselines/reference/jsFileCompilationExternalPackageError.types b/tests/baselines/reference/jsFileCompilationExternalPackageError.types new file mode 100644 index 00000000000..ae2eb085f28 --- /dev/null +++ b/tests/baselines/reference/jsFileCompilationExternalPackageError.types @@ -0,0 +1,34 @@ +=== tests/cases/compiler/moduleA/a.js === + +import {a} from "b"; +>a : any + +a++; +>a++ : number +>a : any + +import {c} from "c"; +>c : any + +c++; +>c++ : number +>c : any + +=== tests/cases/compiler/node_modules/b.ts === +var a = 10; +>a : number +>10 : number + +=== tests/cases/compiler/node_modules/c.js === +exports.a = 10; +>exports.a = 10 : number +>exports.a : any +>exports : any +>a : any +>10 : number + +c = 10; +>c = 10 : number +>c : any +>10 : number + diff --git a/tests/baselines/reference/library-reference-11.trace.json b/tests/baselines/reference/library-reference-11.trace.json index e0af1e39c5a..e81a7e3e158 100644 --- a/tests/baselines/reference/library-reference-11.trace.json +++ b/tests/baselines/reference/library-reference-11.trace.json @@ -1,6 +1,14 @@ [ - "======== Resolving type reference directive 'jquery', containing file '/a/b/consumer.ts', root directory not set. ========", - "Root directory cannot be determined, skipping primary search paths.", + "======== Resolving type reference directive 'jquery', containing file '/a/b/consumer.ts', root directory 'C:\\github\\TypeScript'. ========", + "Resolving with primary search path 'C:\\github\\TypeScript/types/'", + "File 'C:\\github\\TypeScript/types/jquery/package.json' does not exist.", + "File 'C:\\github\\TypeScript/types/jquery/index.d.ts' does not exist.", + "Resolving with primary search path 'C:\\github\\TypeScript/node_modules/'", + "File 'C:\\github\\TypeScript/node_modules/jquery/package.json' does not exist.", + "File 'C:\\github\\TypeScript/node_modules/jquery/index.d.ts' does not exist.", + "Resolving with primary search path 'C:\\github\\TypeScript/node_modules/@types/'", + "File 'C:\\github\\TypeScript/node_modules/@types/jquery/package.json' does not exist.", + "File 'C:\\github\\TypeScript/node_modules/@types/jquery/index.d.ts' does not exist.", "Looking up in 'node_modules' folder, initial location '/a/b'", "File '/a/b/node_modules/jquery.ts' does not exist.", "File '/a/b/node_modules/jquery.d.ts' does not exist.", diff --git a/tests/baselines/reference/library-reference-12.trace.json b/tests/baselines/reference/library-reference-12.trace.json index 2cdf1f5f20a..d46fc884f35 100644 --- a/tests/baselines/reference/library-reference-12.trace.json +++ b/tests/baselines/reference/library-reference-12.trace.json @@ -1,6 +1,14 @@ [ - "======== Resolving type reference directive 'jquery', containing file '/a/b/consumer.ts', root directory not set. ========", - "Root directory cannot be determined, skipping primary search paths.", + "======== Resolving type reference directive 'jquery', containing file '/a/b/consumer.ts', root directory 'C:\\github\\TypeScript'. ========", + "Resolving with primary search path 'C:\\github\\TypeScript/types/'", + "File 'C:\\github\\TypeScript/types/jquery/package.json' does not exist.", + "File 'C:\\github\\TypeScript/types/jquery/index.d.ts' does not exist.", + "Resolving with primary search path 'C:\\github\\TypeScript/node_modules/'", + "File 'C:\\github\\TypeScript/node_modules/jquery/package.json' does not exist.", + "File 'C:\\github\\TypeScript/node_modules/jquery/index.d.ts' does not exist.", + "Resolving with primary search path 'C:\\github\\TypeScript/node_modules/@types/'", + "File 'C:\\github\\TypeScript/node_modules/@types/jquery/package.json' does not exist.", + "File 'C:\\github\\TypeScript/node_modules/@types/jquery/index.d.ts' does not exist.", "Looking up in 'node_modules' folder, initial location '/a/b'", "File '/a/b/node_modules/jquery.ts' does not exist.", "File '/a/b/node_modules/jquery.d.ts' does not exist.", diff --git a/tests/baselines/reference/library-reference-15.trace.json b/tests/baselines/reference/library-reference-15.trace.json index 9a19d75ffac..09c891bc5b1 100644 --- a/tests/baselines/reference/library-reference-15.trace.json +++ b/tests/baselines/reference/library-reference-15.trace.json @@ -1,5 +1,44 @@ [ - "======== Resolving type reference directive 'jquery', containing file not set, root directory not set. ========", - "Root directory cannot be determined, skipping primary search paths.", - "Containing file is not specified and root directory cannot be determined, skipping lookup in 'node_modules' folder." + "======== Resolving type reference directive 'jquery', containing file not set, root directory 'C:\\github\\TypeScript'. ========", + "Resolving with primary search path 'C:\\github\\TypeScript/types/'", + "File 'C:\\github\\TypeScript/types/jquery/package.json' does not exist.", + "File 'C:\\github\\TypeScript/types/jquery/index.d.ts' does not exist.", + "Resolving with primary search path 'C:\\github\\TypeScript/node_modules/'", + "File 'C:\\github\\TypeScript/node_modules/jquery/package.json' does not exist.", + "File 'C:\\github\\TypeScript/node_modules/jquery/index.d.ts' does not exist.", + "Resolving with primary search path 'C:\\github\\TypeScript/node_modules/@types/'", + "File 'C:\\github\\TypeScript/node_modules/@types/jquery/package.json' does not exist.", + "File 'C:\\github\\TypeScript/node_modules/@types/jquery/index.d.ts' does not exist.", + "Looking up in 'node_modules' folder, initial location 'C:\\github\\TypeScript'", + "File 'C:/github/TypeScript/node_modules/jquery.ts' does not exist.", + "File 'C:/github/TypeScript/node_modules/jquery.d.ts' does not exist.", + "File 'C:/github/TypeScript/node_modules/jquery/package.json' does not exist.", + "File 'C:/github/TypeScript/node_modules/jquery/index.ts' does not exist.", + "File 'C:/github/TypeScript/node_modules/jquery/index.d.ts' does not exist.", + "File 'C:/github/TypeScript/node_modules/@types/jquery.ts' does not exist.", + "File 'C:/github/TypeScript/node_modules/@types/jquery.d.ts' does not exist.", + "File 'C:/github/TypeScript/node_modules/@types/jquery/package.json' does not exist.", + "File 'C:/github/TypeScript/node_modules/@types/jquery/index.ts' does not exist.", + "File 'C:/github/TypeScript/node_modules/@types/jquery/index.d.ts' does not exist.", + "File 'C:/github/node_modules/jquery.ts' does not exist.", + "File 'C:/github/node_modules/jquery.d.ts' does not exist.", + "File 'C:/github/node_modules/jquery/package.json' does not exist.", + "File 'C:/github/node_modules/jquery/index.ts' does not exist.", + "File 'C:/github/node_modules/jquery/index.d.ts' does not exist.", + "File 'C:/github/node_modules/@types/jquery.ts' does not exist.", + "File 'C:/github/node_modules/@types/jquery.d.ts' does not exist.", + "File 'C:/github/node_modules/@types/jquery/package.json' does not exist.", + "File 'C:/github/node_modules/@types/jquery/index.ts' does not exist.", + "File 'C:/github/node_modules/@types/jquery/index.d.ts' does not exist.", + "File 'C:/node_modules/jquery.ts' does not exist.", + "File 'C:/node_modules/jquery.d.ts' does not exist.", + "File 'C:/node_modules/jquery/package.json' does not exist.", + "File 'C:/node_modules/jquery/index.ts' does not exist.", + "File 'C:/node_modules/jquery/index.d.ts' does not exist.", + "File 'C:/node_modules/@types/jquery.ts' does not exist.", + "File 'C:/node_modules/@types/jquery.d.ts' does not exist.", + "File 'C:/node_modules/@types/jquery/package.json' does not exist.", + "File 'C:/node_modules/@types/jquery/index.ts' does not exist.", + "File 'C:/node_modules/@types/jquery/index.d.ts' does not exist.", + "======== Type reference directive 'jquery' was not resolved. ========" ] \ No newline at end of file diff --git a/tests/baselines/reference/library-reference-5.trace.json b/tests/baselines/reference/library-reference-5.trace.json index 272009782b5..cf016cbe431 100644 --- a/tests/baselines/reference/library-reference-5.trace.json +++ b/tests/baselines/reference/library-reference-5.trace.json @@ -1,6 +1,14 @@ [ - "======== Resolving type reference directive 'foo', containing file '/src/root.ts', root directory not set. ========", - "Root directory cannot be determined, skipping primary search paths.", + "======== Resolving type reference directive 'foo', containing file '/src/root.ts', root directory 'C:\\github\\TypeScript'. ========", + "Resolving with primary search path 'C:\\github\\TypeScript/types/'", + "File 'C:\\github\\TypeScript/types/foo/package.json' does not exist.", + "File 'C:\\github\\TypeScript/types/foo/index.d.ts' does not exist.", + "Resolving with primary search path 'C:\\github\\TypeScript/node_modules/'", + "File 'C:\\github\\TypeScript/node_modules/foo/package.json' does not exist.", + "File 'C:\\github\\TypeScript/node_modules/foo/index.d.ts' does not exist.", + "Resolving with primary search path 'C:\\github\\TypeScript/node_modules/@types/'", + "File 'C:\\github\\TypeScript/node_modules/@types/foo/package.json' does not exist.", + "File 'C:\\github\\TypeScript/node_modules/@types/foo/index.d.ts' does not exist.", "Looking up in 'node_modules' folder, initial location '/src'", "File '/src/node_modules/foo.ts' does not exist.", "File '/src/node_modules/foo.d.ts' does not exist.", @@ -18,8 +26,16 @@ "File '/node_modules/foo/index.ts' does not exist.", "File '/node_modules/foo/index.d.ts' exist - use it as a name resolution result.", "======== Type reference directive 'foo' was successfully resolved to '/node_modules/foo/index.d.ts', primary: false. ========", - "======== Resolving type reference directive 'bar', containing file '/src/root.ts', root directory not set. ========", - "Root directory cannot be determined, skipping primary search paths.", + "======== Resolving type reference directive 'bar', containing file '/src/root.ts', root directory 'C:\\github\\TypeScript'. ========", + "Resolving with primary search path 'C:\\github\\TypeScript/types/'", + "File 'C:\\github\\TypeScript/types/bar/package.json' does not exist.", + "File 'C:\\github\\TypeScript/types/bar/index.d.ts' does not exist.", + "Resolving with primary search path 'C:\\github\\TypeScript/node_modules/'", + "File 'C:\\github\\TypeScript/node_modules/bar/package.json' does not exist.", + "File 'C:\\github\\TypeScript/node_modules/bar/index.d.ts' does not exist.", + "Resolving with primary search path 'C:\\github\\TypeScript/node_modules/@types/'", + "File 'C:\\github\\TypeScript/node_modules/@types/bar/package.json' does not exist.", + "File 'C:\\github\\TypeScript/node_modules/@types/bar/index.d.ts' does not exist.", "Looking up in 'node_modules' folder, initial location '/src'", "File '/src/node_modules/bar.ts' does not exist.", "File '/src/node_modules/bar.d.ts' does not exist.", @@ -37,8 +53,16 @@ "File '/node_modules/bar/index.ts' does not exist.", "File '/node_modules/bar/index.d.ts' exist - use it as a name resolution result.", "======== Type reference directive 'bar' was successfully resolved to '/node_modules/bar/index.d.ts', primary: false. ========", - "======== Resolving type reference directive 'alpha', containing file '/node_modules/foo/index.d.ts', root directory not set. ========", - "Root directory cannot be determined, skipping primary search paths.", + "======== Resolving type reference directive 'alpha', containing file '/node_modules/foo/index.d.ts', root directory 'C:\\github\\TypeScript'. ========", + "Resolving with primary search path 'C:\\github\\TypeScript/types/'", + "File 'C:\\github\\TypeScript/types/alpha/package.json' does not exist.", + "File 'C:\\github\\TypeScript/types/alpha/index.d.ts' does not exist.", + "Resolving with primary search path 'C:\\github\\TypeScript/node_modules/'", + "File 'C:\\github\\TypeScript/node_modules/alpha/package.json' does not exist.", + "File 'C:\\github\\TypeScript/node_modules/alpha/index.d.ts' does not exist.", + "Resolving with primary search path 'C:\\github\\TypeScript/node_modules/@types/'", + "File 'C:\\github\\TypeScript/node_modules/@types/alpha/package.json' does not exist.", + "File 'C:\\github\\TypeScript/node_modules/@types/alpha/index.d.ts' does not exist.", "Looking up in 'node_modules' folder, initial location '/node_modules/foo'", "File '/node_modules/foo/node_modules/alpha.ts' does not exist.", "File '/node_modules/foo/node_modules/alpha.d.ts' does not exist.", @@ -46,8 +70,16 @@ "File '/node_modules/foo/node_modules/alpha/index.ts' does not exist.", "File '/node_modules/foo/node_modules/alpha/index.d.ts' exist - use it as a name resolution result.", "======== Type reference directive 'alpha' was successfully resolved to '/node_modules/foo/node_modules/alpha/index.d.ts', primary: false. ========", - "======== Resolving type reference directive 'alpha', containing file '/node_modules/bar/index.d.ts', root directory not set. ========", - "Root directory cannot be determined, skipping primary search paths.", + "======== Resolving type reference directive 'alpha', containing file '/node_modules/bar/index.d.ts', root directory 'C:\\github\\TypeScript'. ========", + "Resolving with primary search path 'C:\\github\\TypeScript/types/'", + "File 'C:\\github\\TypeScript/types/alpha/package.json' does not exist.", + "File 'C:\\github\\TypeScript/types/alpha/index.d.ts' does not exist.", + "Resolving with primary search path 'C:\\github\\TypeScript/node_modules/'", + "File 'C:\\github\\TypeScript/node_modules/alpha/package.json' does not exist.", + "File 'C:\\github\\TypeScript/node_modules/alpha/index.d.ts' does not exist.", + "Resolving with primary search path 'C:\\github\\TypeScript/node_modules/@types/'", + "File 'C:\\github\\TypeScript/node_modules/@types/alpha/package.json' does not exist.", + "File 'C:\\github\\TypeScript/node_modules/@types/alpha/index.d.ts' does not exist.", "Looking up in 'node_modules' folder, initial location '/node_modules/bar'", "File '/node_modules/bar/node_modules/alpha.ts' does not exist.", "File '/node_modules/bar/node_modules/alpha.d.ts' does not exist.", diff --git a/tests/baselines/reference/library-reference-7.trace.json b/tests/baselines/reference/library-reference-7.trace.json index 419fe6d055d..bed3cb4fe40 100644 --- a/tests/baselines/reference/library-reference-7.trace.json +++ b/tests/baselines/reference/library-reference-7.trace.json @@ -1,6 +1,14 @@ [ - "======== Resolving type reference directive 'jquery', containing file '/src/consumer.ts', root directory not set. ========", - "Root directory cannot be determined, skipping primary search paths.", + "======== Resolving type reference directive 'jquery', containing file '/src/consumer.ts', root directory 'C:\\github\\TypeScript'. ========", + "Resolving with primary search path 'C:\\github\\TypeScript/types/'", + "File 'C:\\github\\TypeScript/types/jquery/package.json' does not exist.", + "File 'C:\\github\\TypeScript/types/jquery/index.d.ts' does not exist.", + "Resolving with primary search path 'C:\\github\\TypeScript/node_modules/'", + "File 'C:\\github\\TypeScript/node_modules/jquery/package.json' does not exist.", + "File 'C:\\github\\TypeScript/node_modules/jquery/index.d.ts' does not exist.", + "Resolving with primary search path 'C:\\github\\TypeScript/node_modules/@types/'", + "File 'C:\\github\\TypeScript/node_modules/@types/jquery/package.json' does not exist.", + "File 'C:\\github\\TypeScript/node_modules/@types/jquery/index.d.ts' does not exist.", "Looking up in 'node_modules' folder, initial location '/src'", "File '/src/node_modules/jquery.ts' does not exist.", "File '/src/node_modules/jquery.d.ts' does not exist.", diff --git a/tests/baselines/reference/nodeResolution5.errors.txt b/tests/baselines/reference/nodeResolution5.errors.txt deleted file mode 100644 index c36cce45b6d..00000000000 --- a/tests/baselines/reference/nodeResolution5.errors.txt +++ /dev/null @@ -1,14 +0,0 @@ -tests/cases/compiler/b.ts(1,20): error TS2656: Exported external package typings file 'tests/cases/compiler/node_modules/a.d.ts' is not a module. Please contact the package author to update the package definition. - - -==== tests/cases/compiler/b.ts (1 errors) ==== - import y = require("a"); - ~~~ -!!! error TS2656: Exported external package typings file 'a.d.ts' is not a module. Please contact the package author to update the package definition. - -==== tests/cases/compiler/node_modules/a.d.ts (0 errors) ==== - - declare module "a" { - var x: number; - } - \ No newline at end of file diff --git a/tests/baselines/reference/nodeResolution5.symbols b/tests/baselines/reference/nodeResolution5.symbols new file mode 100644 index 00000000000..be4aa2be0e9 --- /dev/null +++ b/tests/baselines/reference/nodeResolution5.symbols @@ -0,0 +1,11 @@ +=== tests/cases/compiler/b.ts === +import y = require("a"); +>y : Symbol(y, Decl(b.ts, 0, 0)) + +=== tests/cases/compiler/node_modules/a.d.ts === + +declare module "a" { + var x: number; +>x : Symbol(x, Decl(a.d.ts, 2, 7)) +} + diff --git a/tests/baselines/reference/nodeResolution5.types b/tests/baselines/reference/nodeResolution5.types new file mode 100644 index 00000000000..14f5bd24f5d --- /dev/null +++ b/tests/baselines/reference/nodeResolution5.types @@ -0,0 +1,11 @@ +=== tests/cases/compiler/b.ts === +import y = require("a"); +>y : typeof y + +=== tests/cases/compiler/node_modules/a.d.ts === + +declare module "a" { + var x: number; +>x : number +} + diff --git a/tests/baselines/reference/nodeResolution6.errors.txt b/tests/baselines/reference/nodeResolution6.errors.txt deleted file mode 100644 index 6bab6e34389..00000000000 --- a/tests/baselines/reference/nodeResolution6.errors.txt +++ /dev/null @@ -1,17 +0,0 @@ -tests/cases/compiler/node_modules/a.d.ts(1,1): error TS2654: Exported external package typings file cannot contain tripleslash references. Please contact the package author to update the package definition. - - -==== tests/cases/compiler/b.ts (0 errors) ==== - import y = require("a"); - -==== tests/cases/compiler/node_modules/ref.ts (0 errors) ==== - - var x = 1; - -==== tests/cases/compiler/node_modules/a.d.ts (1 errors) ==== - /// - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2654: Exported external package typings file cannot contain tripleslash references. Please contact the package author to update the package definition. - export declare var y; - - \ No newline at end of file diff --git a/tests/baselines/reference/nodeResolution6.symbols b/tests/baselines/reference/nodeResolution6.symbols new file mode 100644 index 00000000000..075f94e7992 --- /dev/null +++ b/tests/baselines/reference/nodeResolution6.symbols @@ -0,0 +1,15 @@ +=== tests/cases/compiler/b.ts === +import y = require("a"); +>y : Symbol(y, Decl(b.ts, 0, 0)) + +=== tests/cases/compiler/node_modules/ref.ts === + +var x = 1; +>x : Symbol(x, Decl(ref.ts, 1, 3)) + +=== tests/cases/compiler/node_modules/a.d.ts === +/// +export declare var y; +>y : Symbol(y, Decl(a.d.ts, 1, 18)) + + diff --git a/tests/baselines/reference/nodeResolution6.types b/tests/baselines/reference/nodeResolution6.types new file mode 100644 index 00000000000..13c5d6d9276 --- /dev/null +++ b/tests/baselines/reference/nodeResolution6.types @@ -0,0 +1,16 @@ +=== tests/cases/compiler/b.ts === +import y = require("a"); +>y : typeof y + +=== tests/cases/compiler/node_modules/ref.ts === + +var x = 1; +>x : number +>1 : number + +=== tests/cases/compiler/node_modules/a.d.ts === +/// +export declare var y; +>y : any + + diff --git a/tests/baselines/reference/nodeResolution7.errors.txt b/tests/baselines/reference/nodeResolution7.errors.txt deleted file mode 100644 index f9e8ef7ac0f..00000000000 --- a/tests/baselines/reference/nodeResolution7.errors.txt +++ /dev/null @@ -1,14 +0,0 @@ -tests/cases/compiler/b.ts(1,20): error TS2656: Exported external package typings file 'tests/cases/compiler/node_modules/a/index.d.ts' is not a module. Please contact the package author to update the package definition. - - -==== tests/cases/compiler/b.ts (1 errors) ==== - import y = require("a"); - ~~~ -!!! error TS2656: Exported external package typings file 'index.d.ts' is not a module. Please contact the package author to update the package definition. - -==== tests/cases/compiler/node_modules/a/index.d.ts (0 errors) ==== - - declare module "a" { - var x: number; - } - \ No newline at end of file diff --git a/tests/baselines/reference/nodeResolution7.symbols b/tests/baselines/reference/nodeResolution7.symbols new file mode 100644 index 00000000000..ea8d636b61b --- /dev/null +++ b/tests/baselines/reference/nodeResolution7.symbols @@ -0,0 +1,11 @@ +=== tests/cases/compiler/b.ts === +import y = require("a"); +>y : Symbol(y, Decl(b.ts, 0, 0)) + +=== tests/cases/compiler/node_modules/a/index.d.ts === + +declare module "a" { + var x: number; +>x : Symbol(x, Decl(index.d.ts, 2, 7)) +} + diff --git a/tests/baselines/reference/nodeResolution7.types b/tests/baselines/reference/nodeResolution7.types new file mode 100644 index 00000000000..1cb14150bde --- /dev/null +++ b/tests/baselines/reference/nodeResolution7.types @@ -0,0 +1,11 @@ +=== tests/cases/compiler/b.ts === +import y = require("a"); +>y : typeof y + +=== tests/cases/compiler/node_modules/a/index.d.ts === + +declare module "a" { + var x: number; +>x : number +} + diff --git a/tests/baselines/reference/nodeResolution8.errors.txt b/tests/baselines/reference/nodeResolution8.errors.txt deleted file mode 100644 index 3f14a4313c8..00000000000 --- a/tests/baselines/reference/nodeResolution8.errors.txt +++ /dev/null @@ -1,16 +0,0 @@ -tests/cases/compiler/node_modules/a/index.d.ts(1,1): error TS2654: Exported external package typings file cannot contain tripleslash references. Please contact the package author to update the package definition. - - -==== tests/cases/compiler/b.ts (0 errors) ==== - import y = require("a"); -==== tests/cases/compiler/node_modules/a/ref.ts (0 errors) ==== - - var x = 1; - -==== tests/cases/compiler/node_modules/a/index.d.ts (1 errors) ==== - /// - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2654: Exported external package typings file cannot contain tripleslash references. Please contact the package author to update the package definition. - export declare var y; - - \ No newline at end of file diff --git a/tests/baselines/reference/nodeResolution8.symbols b/tests/baselines/reference/nodeResolution8.symbols new file mode 100644 index 00000000000..27c0941c9b9 --- /dev/null +++ b/tests/baselines/reference/nodeResolution8.symbols @@ -0,0 +1,15 @@ +=== tests/cases/compiler/b.ts === +import y = require("a"); +>y : Symbol(y, Decl(b.ts, 0, 0)) + +=== tests/cases/compiler/node_modules/a/ref.ts === + +var x = 1; +>x : Symbol(x, Decl(ref.ts, 1, 3)) + +=== tests/cases/compiler/node_modules/a/index.d.ts === +/// +export declare var y; +>y : Symbol(y, Decl(index.d.ts, 1, 18)) + + diff --git a/tests/baselines/reference/nodeResolution8.types b/tests/baselines/reference/nodeResolution8.types new file mode 100644 index 00000000000..cced0d3008d --- /dev/null +++ b/tests/baselines/reference/nodeResolution8.types @@ -0,0 +1,16 @@ +=== tests/cases/compiler/b.ts === +import y = require("a"); +>y : typeof y + +=== tests/cases/compiler/node_modules/a/ref.ts === + +var x = 1; +>x : number +>1 : number + +=== tests/cases/compiler/node_modules/a/index.d.ts === +/// +export declare var y; +>y : any + + diff --git a/tests/baselines/reference/typeReferenceDirectives11.trace.json b/tests/baselines/reference/typeReferenceDirectives11.trace.json index be060569d83..bfaae056c9e 100644 --- a/tests/baselines/reference/typeReferenceDirectives11.trace.json +++ b/tests/baselines/reference/typeReferenceDirectives11.trace.json @@ -1,12 +1,12 @@ [ - "======== Resolving type reference directive 'lib', containing file not set, root directory '/'. ========", - "Resolving with primary search path '/types/'", - "File '/types/lib/package.json' does not exist.", - "File '/types/lib/index.d.ts' exist - use it as a name resolution result.", - "======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========", "======== Resolving module './mod1' from '/mod2.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", "Loading module as file / folder, candidate module location '/mod1'.", "File '/mod1.ts' exist - use it as a name resolution result.", - "======== Module name './mod1' was successfully resolved to '/mod1.ts'. ========" + "======== Module name './mod1' was successfully resolved to '/mod1.ts'. ========", + "======== Resolving type reference directive 'lib', containing file not set, root directory '/'. ========", + "Resolving with primary search path '/types/'", + "File '/types/lib/package.json' does not exist.", + "File '/types/lib/index.d.ts' exist - use it as a name resolution result.", + "======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========" ] \ No newline at end of file diff --git a/tests/baselines/reference/typeReferenceDirectives8.trace.json b/tests/baselines/reference/typeReferenceDirectives8.trace.json index be060569d83..bfaae056c9e 100644 --- a/tests/baselines/reference/typeReferenceDirectives8.trace.json +++ b/tests/baselines/reference/typeReferenceDirectives8.trace.json @@ -1,12 +1,12 @@ [ - "======== Resolving type reference directive 'lib', containing file not set, root directory '/'. ========", - "Resolving with primary search path '/types/'", - "File '/types/lib/package.json' does not exist.", - "File '/types/lib/index.d.ts' exist - use it as a name resolution result.", - "======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========", "======== Resolving module './mod1' from '/mod2.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", "Loading module as file / folder, candidate module location '/mod1'.", "File '/mod1.ts' exist - use it as a name resolution result.", - "======== Module name './mod1' was successfully resolved to '/mod1.ts'. ========" + "======== Module name './mod1' was successfully resolved to '/mod1.ts'. ========", + "======== Resolving type reference directive 'lib', containing file not set, root directory '/'. ========", + "Resolving with primary search path '/types/'", + "File '/types/lib/package.json' does not exist.", + "File '/types/lib/index.d.ts' exist - use it as a name resolution result.", + "======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========" ] \ No newline at end of file diff --git a/tests/baselines/reference/typingsLookup1.js b/tests/baselines/reference/typingsLookup1.js new file mode 100644 index 00000000000..1f89a2277aa --- /dev/null +++ b/tests/baselines/reference/typingsLookup1.js @@ -0,0 +1,11 @@ +//// [tests/cases/conformance/typings/typingsLookup1.ts] //// + +//// [index.d.ts] +declare var $: { x: any }; + +//// [a.ts] +$.x; + + +//// [a.js] +$.x; diff --git a/tests/baselines/reference/typingsLookup1.symbols b/tests/baselines/reference/typingsLookup1.symbols new file mode 100644 index 00000000000..8a21252d123 --- /dev/null +++ b/tests/baselines/reference/typingsLookup1.symbols @@ -0,0 +1,11 @@ +=== tests/cases/conformance/typings/a.ts === +$.x; +>$.x : Symbol(x, Decl(index.d.ts, 0, 16)) +>$ : Symbol($, Decl(index.d.ts, 0, 11)) +>x : Symbol(x, Decl(index.d.ts, 0, 16)) + +=== tests/cases/conformance/typings/node_modules/@types/jquery/index.d.ts === +declare var $: { x: any }; +>$ : Symbol($, Decl(index.d.ts, 0, 11)) +>x : Symbol(x, Decl(index.d.ts, 0, 16)) + diff --git a/tests/baselines/reference/typingsLookup1.types b/tests/baselines/reference/typingsLookup1.types new file mode 100644 index 00000000000..ca79a8248d5 --- /dev/null +++ b/tests/baselines/reference/typingsLookup1.types @@ -0,0 +1,11 @@ +=== tests/cases/conformance/typings/a.ts === +$.x; +>$.x : any +>$ : { x: any; } +>x : any + +=== tests/cases/conformance/typings/node_modules/@types/jquery/index.d.ts === +declare var $: { x: any }; +>$ : { x: any; } +>x : any +