From f4e10eb738bcf5e157cf18047c8d930c4d39384b Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Tue, 17 May 2016 15:41:31 -0700 Subject: [PATCH 01/11] Automatically consume /types --- src/compiler/program.ts | 54 ++++++++++++++++++++++++++--------------- src/compiler/sys.ts | 14 +++++++++++ src/compiler/types.ts | 2 ++ 3 files changed, 50 insertions(+), 20 deletions(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 52547cb165d..c8761555d12 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -18,6 +18,8 @@ namespace ts { "node_modules/@types/", ]; + const autoImportedTypePaths = ["types", "node_modules/@types"]; + export const version = "1.9.0"; export function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean): string { @@ -196,8 +198,8 @@ namespace ts { traceEnabled }; - // use typesRoot and fallback to directory that contains tsconfig if typesRoot is not set - const rootDir = options.typesRoot || (options.configFilePath ? getDirectoryPath(options.configFilePath) : undefined); + // use typesRoot and fallback to directory that contains tsconfig or current directory if typesRoot is not set + const rootDir = options.typesRoot || (options.configFilePath ? getDirectoryPath(options.configFilePath) : (host.getCurrentDirectory && host.getCurrentDirectory())); if (traceEnabled) { if (containingFile === undefined) { @@ -875,6 +877,19 @@ namespace ts { } } + function getDefaultTypeDirectiveNames(rootPath: string): string[] { + const localTypes = combinePaths(rootPath, 'types'); + const npmTypes = combinePaths(rootPath, 'node_modules/@types'); + let result: string[] = []; + if (sys.directoryExists(localTypes)) { + result = result.concat(sys.getDirectories(localTypes)); + } + if (sys.directoryExists(npmTypes)) { + result = result.concat(sys.getDirectories(npmTypes)); + } + return result; + } + function getDefaultLibLocation(): string { return getDirectoryPath(normalizePath(sys.getExecutingFilePath())); } @@ -883,6 +898,7 @@ namespace ts { const realpath = sys.realpath && ((path: string) => sys.realpath(path)); return { + getDefaultTypeDirectiveNames, getSourceFile, getDefaultLibLocation, getDefaultLibFileName: options => combinePaths(getDefaultLibLocation(), getDefaultLibFileName(options)), @@ -1006,10 +1022,21 @@ namespace ts { if (!tryReuseStructureFromOldProgram()) { // load type declarations specified via 'types' argument - if (options.types && options.types.length) { - const resolutions = resolveTypeReferenceDirectiveNamesWorker(options.types, /*containingFile*/ undefined); - for (let i = 0; i < options.types.length; i++) { - processTypeReferenceDirective(options.types[i], resolutions[i]); + let typeReferences: string[]; + if (options.types) { + typeReferences = options.types; + } + else { + // or load all types from the automatic type import fields + if (host.getDefaultTypeDirectiveNames) { + typeReferences = host.getDefaultTypeDirectiveNames(getCommonSourceDirectory());; + } + } + + if (typeReferences) { + const resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, /*containingFile*/ undefined); + for (let i = 0; i < typeReferences.length; i++) { + processTypeReferenceDirective(typeReferences[i], resolutions[i]); } } @@ -1914,20 +1941,7 @@ namespace ts { i < file.imports.length; if (shouldAddFile) { - const importedFile = findSourceFile(resolution.resolvedFileName, toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), /*isDefaultLib*/ false, /*isReference*/ false, file, skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); - - if (importedFile && resolution.isExternalLibraryImport) { - // Since currently irrespective of allowJs, we only look for supportedTypeScript extension external module files, - // this check is ok. Otherwise this would be never true for javascript file - if (!isExternalModule(importedFile) && importedFile.statements.length) { - const start = getTokenPosOfNode(file.imports[i], file); - fileProcessingDiagnostics.add(createFileDiagnostic(file, start, file.imports[i].end - start, Diagnostics.Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition, importedFile.fileName)); - } - else if (importedFile.referencedFiles.length) { - const firstRef = importedFile.referencedFiles[0]; - fileProcessingDiagnostics.add(createFileDiagnostic(importedFile, firstRef.pos, firstRef.end - firstRef.pos, Diagnostics.Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition)); - } - } + findSourceFile(resolution.resolvedFileName, toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), /*isDefaultLib*/ false, /*isReference*/ false, file, skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); } } } diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index a9a39f42240..6669a6fca24 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -24,6 +24,7 @@ namespace ts { createDirectory(path: string): void; getExecutingFilePath(): string; getCurrentDirectory(): string; + getDirectories(path: string): string[]; readDirectory(path: string, extension?: string, exclude?: string[]): string[]; getModifiedTime?(path: string): Date; createHash?(data: string): string; @@ -71,6 +72,7 @@ namespace ts { resolvePath(path: string): string; readFile(path: string): string; writeFile(path: string, contents: string): void; + getDirectories(path: string): string[]; readDirectory(path: string, extension?: string, exclude?: string[]): string[]; watchFile?(path: string, callback: FileWatcherCallback): FileWatcher; watchDirectory?(path: string, callback: DirectoryWatcherCallback, recursive?: boolean): FileWatcher; @@ -161,6 +163,11 @@ namespace ts { return result.sort(); } + function getDirectories(path: string): string[] { + const folder = fso.GetFolder(path); + return getNames(folder.subfolders); + } + function readDirectory(path: string, extension?: string, exclude?: string[]): string[] { const result: string[] = []; exclude = map(exclude, s => getCanonicalPath(combinePaths(path, s))); @@ -214,6 +221,7 @@ namespace ts { getCurrentDirectory() { return new ActiveXObject("WScript.Shell").CurrentDirectory; }, + getDirectories, readDirectory, exit(exitCode?: number): void { try { @@ -402,6 +410,10 @@ namespace ts { return fileSystemEntryExists(path, FileSystemEntryKind.Directory); } + function getDirectories(path: string): string[] { + return _fs.readdirSync(path); + } + function readDirectory(path: string, extension?: string, exclude?: string[]): string[] { const result: string[] = []; exclude = map(exclude, s => getCanonicalPath(combinePaths(path, s))); @@ -507,6 +519,7 @@ namespace ts { getCurrentDirectory() { return process.cwd(); }, + getDirectories, readDirectory, getModifiedTime(path) { try { @@ -561,6 +574,7 @@ namespace ts { createDirectory: ChakraHost.createDirectory, getExecutingFilePath: () => ChakraHost.executingFile, getCurrentDirectory: () => ChakraHost.currentDirectory, + getDirectories: ChakraHost.getDirectories, readDirectory: ChakraHost.readDirectory, exit: ChakraHost.quit, realpath diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 777141b45fb..877a1a330fe 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2784,6 +2784,7 @@ namespace ts { trace?(s: string): void; directoryExists?(directoryName: string): boolean; realpath?(path: string): string; + getCurrentDirectory?(): string; } export interface ResolvedModule { @@ -2820,6 +2821,7 @@ namespace ts { getCancellationToken?(): CancellationToken; getDefaultLibFileName(options: CompilerOptions): string; getDefaultLibLocation?(): string; + getDefaultTypeDirectiveNames?(rootPath: string): string[]; writeFile: WriteFileCallback; getCurrentDirectory(): string; getCanonicalFileName(fileName: string): string; From 917ab0aa0afa7501ff0dc75f3ee191718e03eaac Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Wed, 18 May 2016 10:43:44 -0700 Subject: [PATCH 02/11] Update test harness --- src/harness/harness.ts | 38 +++++++++++++------ src/harness/harnessLanguageService.ts | 4 ++ .../conformance/typings/typingsLookup1.ts | 10 +++++ .../cases/unittests/cachingInServerLSHost.ts | 1 + tests/cases/unittests/session.ts | 1 + 5 files changed, 42 insertions(+), 12 deletions(-) create mode 100644 tests/cases/conformance/typings/typingsLookup1.ts diff --git a/src/harness/harness.ts b/src/harness/harness.ts index ef9b36b50e2..ca8102b2ff4 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -127,7 +127,7 @@ namespace Utils { export function memoize(f: T): T { const cache: { [idx: string]: any } = {}; - return (function () { + return (function() { const key = Array.prototype.join.call(arguments); const cachedResult = cache[key]; if (cachedResult) { @@ -609,7 +609,7 @@ namespace Harness { export const getCurrentDirectory = () => ""; export const args = () => []; export const getExecutingFilePath = () => ""; - export const exit = (exitCode: number) => {}; + export const exit = (exitCode: number) => { }; export let log = (s: string) => console.log(s); @@ -826,7 +826,7 @@ namespace Harness { } if (!libFileNameSourceFileMap[fileName]) { - libFileNameSourceFileMap[fileName] = createSourceFileAndAssertInvariants(fileName, IO.readFile(libFolder + fileName), ts.ScriptTarget.Latest); + libFileNameSourceFileMap[fileName] = createSourceFileAndAssertInvariants(fileName, IO.readFile(libFolder + fileName), ts.ScriptTarget.Latest); } return libFileNameSourceFileMap[fileName]; } @@ -900,6 +900,20 @@ namespace Harness { return { + getDefaultTypeDirectiveNames: (path: string) => { + const results: string[] = []; + fileMap.forEachValue((key, value) => { + const rx = /node_modules\/@types\/(\w+)/; + const typeNameResult = rx.exec(key); + if(typeNameResult) { + const typeName = typeNameResult[1]; + if (results.indexOf(typeName) < 0) { + results.push(typeName); + } + } + }); + return results; + }, getCurrentDirectory: () => currentDirectory, getSourceFile, getDefaultLibFileName, @@ -1441,12 +1455,12 @@ namespace Harness { if (currentFileName) { // Store result file const newTestFile = { - content: currentFileContent, - name: currentFileName, - fileOptions: currentFileOptions, - originalFilePath: fileName, - references: refs - }; + content: currentFileContent, + name: currentFileName, + fileOptions: currentFileOptions, + originalFilePath: fileName, + references: refs + }; testUnitData.push(newTestFile); // Reset local data @@ -1544,10 +1558,10 @@ namespace Harness { function baselinePath(fileName: string, type: string, baselineFolder: string, subfolder?: string) { if (subfolder !== undefined) { - return Harness.userSpecifiedRoot + baselineFolder + "/" + subfolder + "/" + type + "/" + fileName; + return Harness.userSpecifiedRoot + baselineFolder + "/" + subfolder + "/" + type + "/" + fileName; } else { - return Harness.userSpecifiedRoot + baselineFolder + "/" + type + "/" + fileName; + return Harness.userSpecifiedRoot + baselineFolder + "/" + type + "/" + fileName; } } @@ -1616,7 +1630,7 @@ namespace Harness { } function writeComparison(expected: string, actual: string, relativeFileName: string, actualFileName: string, descriptionForDescribe: string) { - const encoded_actual = Utils.encodeString(actual); + const encoded_actual = Utils.encodeString(actual); if (expected != encoded_actual) { // Overwrite & issue error const errMsg = "The baseline file " + relativeFileName + " has changed."; diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index 8aaff65febc..3df0e8e7d8f 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -600,6 +600,10 @@ namespace Harness.LanguageService { return this.host.getCurrentDirectory(); } + getDirectories(path: string): string[] { + return []; + } + readDirectory(path: string, extension?: string): string[] { throw new Error("Not implemented Yet."); } diff --git a/tests/cases/conformance/typings/typingsLookup1.ts b/tests/cases/conformance/typings/typingsLookup1.ts new file mode 100644 index 00000000000..702bd4bc21c --- /dev/null +++ b/tests/cases/conformance/typings/typingsLookup1.ts @@ -0,0 +1,10 @@ +// @noImplicitReferences: true + +// @filename: tsconfig.json +{ "files": "a.ts" } + +// @filename: node_modules/@types/jquery/index.d.ts +declare var $: { x: any }; + +// @filename: a.ts +$.x; diff --git a/tests/cases/unittests/cachingInServerLSHost.ts b/tests/cases/unittests/cachingInServerLSHost.ts index 58bcd76e246..899b59c1600 100644 --- a/tests/cases/unittests/cachingInServerLSHost.ts +++ b/tests/cases/unittests/cachingInServerLSHost.ts @@ -46,6 +46,7 @@ module ts { getCurrentDirectory: (): string => { return ""; }, + getDirectories: (path: string) => [], readDirectory: (path: string, extension?: string, exclude?: string[]): string[] => { throw new Error("NYI"); }, diff --git a/tests/cases/unittests/session.ts b/tests/cases/unittests/session.ts index ee9742482cd..40be5fee411 100644 --- a/tests/cases/unittests/session.ts +++ b/tests/cases/unittests/session.ts @@ -14,6 +14,7 @@ namespace ts.server { resolvePath(): string { return void 0; }, fileExists: () => false, directoryExists: () => false, + getDirectories: () => [], createDirectory(): void {}, getExecutingFilePath(): string { return void 0; }, getCurrentDirectory(): string { return void 0; }, From f0e3ebe37db16914a609130c0f4390a8bd9bedf5 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Wed, 18 May 2016 11:12:02 -0700 Subject: [PATCH 03/11] Lint --- src/compiler/program.ts | 8 +++----- src/harness/harness.ts | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index c8761555d12..ba21461e2a0 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -18,8 +18,6 @@ namespace ts { "node_modules/@types/", ]; - const autoImportedTypePaths = ["types", "node_modules/@types"]; - export const version = "1.9.0"; export function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean): string { @@ -878,8 +876,8 @@ namespace ts { } function getDefaultTypeDirectiveNames(rootPath: string): string[] { - const localTypes = combinePaths(rootPath, 'types'); - const npmTypes = combinePaths(rootPath, 'node_modules/@types'); + const localTypes = combinePaths(rootPath, "types"); + const npmTypes = combinePaths(rootPath, "node_modules/@types"); let result: string[] = []; if (sys.directoryExists(localTypes)) { result = result.concat(sys.getDirectories(localTypes)); @@ -1029,7 +1027,7 @@ namespace ts { else { // or load all types from the automatic type import fields if (host.getDefaultTypeDirectiveNames) { - typeReferences = host.getDefaultTypeDirectiveNames(getCommonSourceDirectory());; + typeReferences = host.getDefaultTypeDirectiveNames(getCommonSourceDirectory()); } } diff --git a/src/harness/harness.ts b/src/harness/harness.ts index ca8102b2ff4..92482386138 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -905,7 +905,7 @@ namespace Harness { fileMap.forEachValue((key, value) => { const rx = /node_modules\/@types\/(\w+)/; const typeNameResult = rx.exec(key); - if(typeNameResult) { + if (typeNameResult) { const typeName = typeNameResult[1]; if (results.indexOf(typeName) < 0) { results.push(typeName); From 58b11b631ffc179a7b9fe348101c19ab3f4a9068 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Wed, 18 May 2016 11:30:40 -0700 Subject: [PATCH 04/11] Baseline accept and reorder program logic so common source dir is right --- src/compiler/program.ts | 8 +++- ...CompilationExternalPackageError.errors.txt | 19 -------- ...ileCompilationExternalPackageError.symbols | 25 ++++++++++ ...sFileCompilationExternalPackageError.types | 34 +++++++++++++ .../reference/library-reference-11.trace.json | 12 ++++- .../reference/library-reference-12.trace.json | 12 ++++- .../reference/library-reference-15.trace.json | 45 +++++++++++++++-- .../reference/library-reference-5.trace.json | 48 +++++++++++++++---- .../reference/library-reference-7.trace.json | 12 ++++- .../reference/nodeResolution5.errors.txt | 14 ------ .../reference/nodeResolution5.symbols | 11 +++++ .../baselines/reference/nodeResolution5.types | 11 +++++ .../reference/nodeResolution6.errors.txt | 17 ------- .../reference/nodeResolution6.symbols | 15 ++++++ .../baselines/reference/nodeResolution6.types | 16 +++++++ .../reference/nodeResolution7.errors.txt | 14 ------ .../reference/nodeResolution7.symbols | 11 +++++ .../baselines/reference/nodeResolution7.types | 11 +++++ .../reference/nodeResolution8.errors.txt | 16 ------- .../reference/nodeResolution8.symbols | 15 ++++++ .../baselines/reference/nodeResolution8.types | 16 +++++++ .../typeReferenceDirectives11.trace.json | 12 ++--- .../typeReferenceDirectives8.trace.json | 12 ++--- tests/baselines/reference/typingsLookup1.js | 11 +++++ .../reference/typingsLookup1.symbols | 11 +++++ .../baselines/reference/typingsLookup1.types | 11 +++++ 26 files changed, 328 insertions(+), 111 deletions(-) delete mode 100644 tests/baselines/reference/jsFileCompilationExternalPackageError.errors.txt create mode 100644 tests/baselines/reference/jsFileCompilationExternalPackageError.symbols create mode 100644 tests/baselines/reference/jsFileCompilationExternalPackageError.types delete mode 100644 tests/baselines/reference/nodeResolution5.errors.txt create mode 100644 tests/baselines/reference/nodeResolution5.symbols create mode 100644 tests/baselines/reference/nodeResolution5.types delete mode 100644 tests/baselines/reference/nodeResolution6.errors.txt create mode 100644 tests/baselines/reference/nodeResolution6.symbols create mode 100644 tests/baselines/reference/nodeResolution6.types delete mode 100644 tests/baselines/reference/nodeResolution7.errors.txt create mode 100644 tests/baselines/reference/nodeResolution7.symbols create mode 100644 tests/baselines/reference/nodeResolution7.types delete mode 100644 tests/baselines/reference/nodeResolution8.errors.txt create mode 100644 tests/baselines/reference/nodeResolution8.symbols create mode 100644 tests/baselines/reference/nodeResolution8.types create mode 100644 tests/baselines/reference/typingsLookup1.js create mode 100644 tests/baselines/reference/typingsLookup1.symbols create mode 100644 tests/baselines/reference/typingsLookup1.types 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 + From 0e273e190e7564a7ed772d93ab05d7716782dd45 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Wed, 18 May 2016 14:37:40 -0700 Subject: [PATCH 05/11] Get rid of disk-based paths in baselines --- src/harness/compilerRunner.ts | 2 +- src/harness/harness.ts | 1 + .../reference/library-reference-11.trace.json | 20 ++-- .../reference/library-reference-12.trace.json | 20 ++-- .../reference/library-reference-15.trace.json | 62 ++++------- .../reference/library-reference-5.trace.json | 102 ++++++------------ .../reference/library-reference-7.trace.json | 20 ++-- .../references/library-reference-11.ts | 1 + .../references/library-reference-12.ts | 1 + .../references/library-reference-15.ts | 1 + .../references/library-reference-5.ts | 1 + .../references/library-reference-7.ts | 1 + 12 files changed, 90 insertions(+), 142 deletions(-) diff --git a/src/harness/compilerRunner.ts b/src/harness/compilerRunner.ts index 1ddbd1ea331..1069a1bc97e 100644 --- a/src/harness/compilerRunner.ts +++ b/src/harness/compilerRunner.ts @@ -107,7 +107,7 @@ class CompilerBaselineRunner extends RunnerBase { } const output = Harness.Compiler.compileFiles( - toBeCompiled, otherFiles, harnessSettings, /*options*/ tsConfigOptions, /*currentDirectory*/ undefined); + toBeCompiled, otherFiles, harnessSettings, /*options*/ tsConfigOptions, /*currentDirectory*/ harnessSettings['currentDirectory']); options = output.options; result = output.result; diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 92482386138..5b26829cf4a 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -953,6 +953,7 @@ namespace Harness { { name: "noErrorTruncation", type: "boolean" }, { name: "suppressOutputPathCheck", type: "boolean" }, { name: "noImplicitReferences", type: "boolean" }, + { name: "currentDirectory", type: "string" }, { name: "symlink", type: "string" } ]; diff --git a/tests/baselines/reference/library-reference-11.trace.json b/tests/baselines/reference/library-reference-11.trace.json index e81a7e3e158..62d828d57d6 100644 --- a/tests/baselines/reference/library-reference-11.trace.json +++ b/tests/baselines/reference/library-reference-11.trace.json @@ -1,14 +1,14 @@ [ - "======== 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.", + "======== Resolving type reference directive 'jquery', containing file '/a/b/consumer.ts', root directory '/'. ========", + "Resolving with primary search path '/types/'", + "File '/types/jquery/package.json' does not exist.", + "File '/types/jquery/index.d.ts' does not exist.", + "Resolving with primary search path '/node_modules/'", + "File '/node_modules/jquery/package.json' does not exist.", + "File '/node_modules/jquery/index.d.ts' does not exist.", + "Resolving with primary search path '/node_modules/@types/'", + "File '/node_modules/@types/jquery/package.json' does not exist.", + "File '/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 d46fc884f35..abe1f6c0f46 100644 --- a/tests/baselines/reference/library-reference-12.trace.json +++ b/tests/baselines/reference/library-reference-12.trace.json @@ -1,14 +1,14 @@ [ - "======== 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.", + "======== Resolving type reference directive 'jquery', containing file '/a/b/consumer.ts', root directory '/'. ========", + "Resolving with primary search path '/types/'", + "File '/types/jquery/package.json' does not exist.", + "File '/types/jquery/index.d.ts' does not exist.", + "Resolving with primary search path '/node_modules/'", + "File '/node_modules/jquery/package.json' does not exist.", + "File '/node_modules/jquery/index.d.ts' does not exist.", + "Resolving with primary search path '/node_modules/@types/'", + "File '/node_modules/@types/jquery/package.json' does not exist.", + "File '/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 09c891bc5b1..b8029a0b61f 100644 --- a/tests/baselines/reference/library-reference-15.trace.json +++ b/tests/baselines/reference/library-reference-15.trace.json @@ -1,44 +1,24 @@ [ - "======== 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.", + "======== Resolving type reference directive 'jquery', containing file not set, root directory '/'. ========", + "Resolving with primary search path '/types/'", + "File '/types/jquery/package.json' does not exist.", + "File '/types/jquery/index.d.ts' does not exist.", + "Resolving with primary search path '/node_modules/'", + "File '/node_modules/jquery/package.json' does not exist.", + "File '/node_modules/jquery/index.d.ts' does not exist.", + "Resolving with primary search path '/node_modules/@types/'", + "File '/node_modules/@types/jquery/package.json' does not exist.", + "File '/node_modules/@types/jquery/index.d.ts' does not exist.", + "Looking up in 'node_modules' folder, initial location '/'", + "File '/node_modules/jquery.ts' does not exist.", + "File '/node_modules/jquery.d.ts' does not exist.", + "File '/node_modules/jquery/package.json' does not exist.", + "File '/node_modules/jquery/index.ts' does not exist.", + "File '/node_modules/jquery/index.d.ts' does not exist.", + "File '/node_modules/@types/jquery.ts' does not exist.", + "File '/node_modules/@types/jquery.d.ts' does not exist.", + "File '/node_modules/@types/jquery/package.json' does not exist.", + "File '/node_modules/@types/jquery/index.ts' does not exist.", + "File '/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 cf016cbe431..ad34e9e3159 100644 --- a/tests/baselines/reference/library-reference-5.trace.json +++ b/tests/baselines/reference/library-reference-5.trace.json @@ -1,68 +1,30 @@ [ - "======== 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.", - "File '/src/node_modules/foo/package.json' does not exist.", - "File '/src/node_modules/foo/index.ts' does not exist.", - "File '/src/node_modules/foo/index.d.ts' does not exist.", - "File '/src/node_modules/@types/foo.ts' does not exist.", - "File '/src/node_modules/@types/foo.d.ts' does not exist.", - "File '/src/node_modules/@types/foo/package.json' does not exist.", - "File '/src/node_modules/@types/foo/index.ts' does not exist.", - "File '/src/node_modules/@types/foo/index.d.ts' does not exist.", - "File '/node_modules/foo.ts' does not exist.", - "File '/node_modules/foo.d.ts' does not exist.", + "======== Resolving type reference directive 'foo', containing file '/src/root.ts', root directory '/'. ========", + "Resolving with primary search path '/types/'", + "File '/types/foo/package.json' does not exist.", + "File '/types/foo/index.d.ts' does not exist.", + "Resolving with primary search path '/node_modules/'", "File '/node_modules/foo/package.json' does not exist.", - "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 '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.", - "File '/src/node_modules/bar/package.json' does not exist.", - "File '/src/node_modules/bar/index.ts' does not exist.", - "File '/src/node_modules/bar/index.d.ts' does not exist.", - "File '/src/node_modules/@types/bar.ts' does not exist.", - "File '/src/node_modules/@types/bar.d.ts' does not exist.", - "File '/src/node_modules/@types/bar/package.json' does not exist.", - "File '/src/node_modules/@types/bar/index.ts' does not exist.", - "File '/src/node_modules/@types/bar/index.d.ts' does not exist.", - "File '/node_modules/bar.ts' does not exist.", - "File '/node_modules/bar.d.ts' does not exist.", + "======== Type reference directive 'foo' was successfully resolved to '/node_modules/foo/index.d.ts', primary: true. ========", + "======== Resolving type reference directive 'bar', containing file '/src/root.ts', root directory '/'. ========", + "Resolving with primary search path '/types/'", + "File '/types/bar/package.json' does not exist.", + "File '/types/bar/index.d.ts' does not exist.", + "Resolving with primary search path '/node_modules/'", "File '/node_modules/bar/package.json' does not exist.", - "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 '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.", + "======== Type reference directive 'bar' was successfully resolved to '/node_modules/bar/index.d.ts', primary: true. ========", + "======== Resolving type reference directive 'alpha', containing file '/node_modules/foo/index.d.ts', root directory '/'. ========", + "Resolving with primary search path '/types/'", + "File '/types/alpha/package.json' does not exist.", + "File '/types/alpha/index.d.ts' does not exist.", + "Resolving with primary search path '/node_modules/'", + "File '/node_modules/alpha/package.json' does not exist.", + "File '/node_modules/alpha/index.d.ts' does not exist.", + "Resolving with primary search path '/node_modules/@types/'", + "File '/node_modules/@types/alpha/package.json' does not exist.", + "File '/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.", @@ -70,16 +32,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 '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.", + "======== Resolving type reference directive 'alpha', containing file '/node_modules/bar/index.d.ts', root directory '/'. ========", + "Resolving with primary search path '/types/'", + "File '/types/alpha/package.json' does not exist.", + "File '/types/alpha/index.d.ts' does not exist.", + "Resolving with primary search path '/node_modules/'", + "File '/node_modules/alpha/package.json' does not exist.", + "File '/node_modules/alpha/index.d.ts' does not exist.", + "Resolving with primary search path '/node_modules/@types/'", + "File '/node_modules/@types/alpha/package.json' does not exist.", + "File '/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 bed3cb4fe40..9c6b19390d0 100644 --- a/tests/baselines/reference/library-reference-7.trace.json +++ b/tests/baselines/reference/library-reference-7.trace.json @@ -1,14 +1,14 @@ [ - "======== 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.", + "======== Resolving type reference directive 'jquery', containing file '/src/consumer.ts', root directory '/'. ========", + "Resolving with primary search path '/types/'", + "File '/types/jquery/package.json' does not exist.", + "File '/types/jquery/index.d.ts' does not exist.", + "Resolving with primary search path '/node_modules/'", + "File '/node_modules/jquery/package.json' does not exist.", + "File '/node_modules/jquery/index.d.ts' does not exist.", + "Resolving with primary search path '/node_modules/@types/'", + "File '/node_modules/@types/jquery/package.json' does not exist.", + "File '/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/cases/conformance/references/library-reference-11.ts b/tests/cases/conformance/references/library-reference-11.ts index 39c8af56543..6708ceb4ab3 100644 --- a/tests/cases/conformance/references/library-reference-11.ts +++ b/tests/cases/conformance/references/library-reference-11.ts @@ -1,5 +1,6 @@ // @noImplicitReferences: true // @traceResolution: true +// @currentDirectory: / // package.json in a secondary reference can refer to another file diff --git a/tests/cases/conformance/references/library-reference-12.ts b/tests/cases/conformance/references/library-reference-12.ts index c61d6d916ff..3db7fd3bc6f 100644 --- a/tests/cases/conformance/references/library-reference-12.ts +++ b/tests/cases/conformance/references/library-reference-12.ts @@ -1,5 +1,6 @@ // @noImplicitReferences: true // @traceResolution: true +// @currentDirectory: / // package.json in a secondary reference can refer to another file diff --git a/tests/cases/conformance/references/library-reference-15.ts b/tests/cases/conformance/references/library-reference-15.ts index 92c96e74c97..dd2179d1af6 100644 --- a/tests/cases/conformance/references/library-reference-15.ts +++ b/tests/cases/conformance/references/library-reference-15.ts @@ -1,6 +1,7 @@ // @noImplicitReferences: true // @traceResolution: true // @types: jquery +// @currentDirectory: / // @filename: /a/types/jquery/index.d.ts declare var $: { foo(): void }; diff --git a/tests/cases/conformance/references/library-reference-5.ts b/tests/cases/conformance/references/library-reference-5.ts index 4660da00a2a..1fe327a1c69 100644 --- a/tests/cases/conformance/references/library-reference-5.ts +++ b/tests/cases/conformance/references/library-reference-5.ts @@ -1,5 +1,6 @@ // @noImplicitReferences: true // @traceResolution: true +// @currentDirectory: / // Secondary references may not be duplicated if they disagree in content diff --git a/tests/cases/conformance/references/library-reference-7.ts b/tests/cases/conformance/references/library-reference-7.ts index e938aef7d3a..a5052415562 100644 --- a/tests/cases/conformance/references/library-reference-7.ts +++ b/tests/cases/conformance/references/library-reference-7.ts @@ -1,5 +1,6 @@ // @noImplicitReferences: true // @traceResolution: true +// @currentDirectory: / // Secondary references are possible From 0a37c697ed79387c3e528da13a1cb710782537c3 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Wed, 18 May 2016 15:03:10 -0700 Subject: [PATCH 06/11] Lint --- src/harness/compilerRunner.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/harness/compilerRunner.ts b/src/harness/compilerRunner.ts index 1069a1bc97e..d368293bd65 100644 --- a/src/harness/compilerRunner.ts +++ b/src/harness/compilerRunner.ts @@ -107,7 +107,7 @@ class CompilerBaselineRunner extends RunnerBase { } const output = Harness.Compiler.compileFiles( - toBeCompiled, otherFiles, harnessSettings, /*options*/ tsConfigOptions, /*currentDirectory*/ harnessSettings['currentDirectory']); + toBeCompiled, otherFiles, harnessSettings, /*options*/ tsConfigOptions, /*currentDirectory*/ harnessSettings["currentDirectory"]); options = output.options; result = output.result; From 1c253239e673695d54aa96dd991350e63cccf03e Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Mon, 23 May 2016 14:51:39 -0700 Subject: [PATCH 07/11] Refactor --- src/compiler/program.ts | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 5ada898acb6..d1b6f2b3ffd 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -972,6 +972,23 @@ namespace ts { return resolutions; } + export function getDefaultTypeDirectiveNames(options: CompilerOptions, rootFiles: string[], host: CompilerHost): string[] { + // Use explicit type list from tsconfig.json + if (options.types) { + return options.types; + } + + // or load all types from the automatic type import fields + if (host && host.getDefaultTypeDirectiveNames) { + const commonRoot = computeCommonSourceDirectoryOfFilenames(rootFiles, host.getCurrentDirectory(), host.getCanonicalFileName); + if (commonRoot) { + return host.getDefaultTypeDirectiveNames(commonRoot); + } + } + + return undefined; + } + export function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program { let program: Program; let files: SourceFile[] = []; @@ -1022,19 +1039,7 @@ namespace ts { forEach(rootNames, name => processRootFile(name, /*isDefaultLib*/ false)); // load type declarations specified via 'types' argument - let typeReferences: string[]; - if (options.types) { - typeReferences = options.types; - } - else { - // or load all types from the automatic type import fields - if (host.getDefaultTypeDirectiveNames) { - const commonRoot = getCommonSourceDirectory(); - if (commonRoot) { - typeReferences = host.getDefaultTypeDirectiveNames(commonRoot); - } - } - } + let typeReferences: string[] = getDefaultTypeDirectiveNames(options, rootNames, host); if (typeReferences) { const resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, /*containingFile*/ undefined); From 3ee4a2283fc6265abd6391f4ddd118b20b31662b Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Mon, 23 May 2016 15:47:04 -0700 Subject: [PATCH 08/11] Lint --- src/compiler/program.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index d1b6f2b3ffd..c3a79ea58d6 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -985,7 +985,7 @@ namespace ts { return host.getDefaultTypeDirectiveNames(commonRoot); } } - + return undefined; } @@ -1039,7 +1039,7 @@ namespace ts { forEach(rootNames, name => processRootFile(name, /*isDefaultLib*/ false)); // load type declarations specified via 'types' argument - let typeReferences: string[] = getDefaultTypeDirectiveNames(options, rootNames, host); + const typeReferences: string[] = getDefaultTypeDirectiveNames(options, rootNames, host); if (typeReferences) { const resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, /*containingFile*/ undefined); From 2d5f38c2bc7257d7fa82a42fb86e97bdde597072 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Mon, 23 May 2016 16:20:13 -0700 Subject: [PATCH 09/11] Only return dirs from getdirectories --- src/compiler/sys.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index 6669a6fca24..0c500d5500e 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -411,7 +411,7 @@ namespace ts { } function getDirectories(path: string): string[] { - return _fs.readdirSync(path); + return filter(_fs.readdirSync(path), p => fileSystemEntryExists(combinePaths(path, p), FileSystemEntryKind.Directory)); } function readDirectory(path: string, extension?: string, exclude?: string[]): string[] { From f7cc05482b783c48d9bc912ae8821d2d38dbe9bd Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Mon, 23 May 2016 16:25:25 -0700 Subject: [PATCH 10/11] Don't lose host 'this' --- src/compiler/program.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index c3a79ea58d6..c7dc47b0006 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -980,7 +980,7 @@ namespace ts { // or load all types from the automatic type import fields if (host && host.getDefaultTypeDirectiveNames) { - const commonRoot = computeCommonSourceDirectoryOfFilenames(rootFiles, host.getCurrentDirectory(), host.getCanonicalFileName); + const commonRoot = computeCommonSourceDirectoryOfFilenames(rootFiles, host.getCurrentDirectory(), f => host.getCanonicalFileName(f)); if (commonRoot) { return host.getDefaultTypeDirectiveNames(commonRoot); } From 4b133489a1c118296e5b3fe356bef4ef926c3356 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Tue, 24 May 2016 11:10:57 -0700 Subject: [PATCH 11/11] Add getDirectories to shims --- lib/lib.scriptHost.d.ts | 294 -------------------------- src/harness/harnessLanguageService.ts | 2 + src/services/shims.ts | 5 + 3 files changed, 7 insertions(+), 294 deletions(-) delete mode 100644 lib/lib.scriptHost.d.ts diff --git a/lib/lib.scriptHost.d.ts b/lib/lib.scriptHost.d.ts deleted file mode 100644 index d4c6131fd93..00000000000 --- a/lib/lib.scriptHost.d.ts +++ /dev/null @@ -1,294 +0,0 @@ -/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. All rights reserved. -Licensed under the Apache License, Version 2.0 (the "License"); you may not use -this file except in compliance with the License. You may obtain a copy of the -License at http://www.apache.org/licenses/LICENSE-2.0 - -THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED -WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, -MERCHANTABLITY OR NON-INFRINGEMENT. - -See the Apache Version 2.0 License for specific language governing permissions -and limitations under the License. -***************************************************************************** */ - -/// - - -///////////////////////////// -/// Windows Script Host APIS -///////////////////////////// - - -interface ActiveXObject { - new (s: string): any; -} -declare var ActiveXObject: ActiveXObject; - -interface ITextWriter { - Write(s: string): void; - WriteLine(s: string): void; - Close(): void; -} - -interface TextStreamBase { - /** - * The column number of the current character position in an input stream. - */ - Column: number; - - /** - * The current line number in an input stream. - */ - Line: number; - - /** - * Closes a text stream. - * It is not necessary to close standard streams; they close automatically when the process ends. If - * you close a standard stream, be aware that any other pointers to that standard stream become invalid. - */ - Close(): void; -} - -interface TextStreamWriter extends TextStreamBase { - /** - * Sends a string to an output stream. - */ - Write(s: string): void; - - /** - * Sends a specified number of blank lines (newline characters) to an output stream. - */ - WriteBlankLines(intLines: number): void; - - /** - * Sends a string followed by a newline character to an output stream. - */ - WriteLine(s: string): void; -} - -interface TextStreamReader extends TextStreamBase { - /** - * Returns a specified number of characters from an input stream, starting at the current pointer position. - * Does not return until the ENTER key is pressed. - * Can only be used on a stream in reading mode; causes an error in writing or appending mode. - */ - Read(characters: number): string; - - /** - * Returns all characters from an input stream. - * Can only be used on a stream in reading mode; causes an error in writing or appending mode. - */ - ReadAll(): string; - - /** - * Returns an entire line from an input stream. - * Although this method extracts the newline character, it does not add it to the returned string. - * Can only be used on a stream in reading mode; causes an error in writing or appending mode. - */ - ReadLine(): string; - - /** - * Skips a specified number of characters when reading from an input text stream. - * Can only be used on a stream in reading mode; causes an error in writing or appending mode. - * @param characters Positive number of characters to skip forward. (Backward skipping is not supported.) - */ - Skip(characters: number): void; - - /** - * Skips the next line when reading from an input text stream. - * Can only be used on a stream in reading mode, not writing or appending mode. - */ - SkipLine(): void; - - /** - * Indicates whether the stream pointer position is at the end of a line. - */ - AtEndOfLine: boolean; - - /** - * Indicates whether the stream pointer position is at the end of a stream. - */ - AtEndOfStream: boolean; -} - -declare var WScript: { - /** - * Outputs text to either a message box (under WScript.exe) or the command console window followed by - * a newline (under CScript.exe). - */ - Echo(s: any): void; - - /** - * Exposes the write-only error output stream for the current script. - * Can be accessed only while using CScript.exe. - */ - StdErr: TextStreamWriter; - - /** - * Exposes the write-only output stream for the current script. - * Can be accessed only while using CScript.exe. - */ - StdOut: TextStreamWriter; - Arguments: { length: number; Item(n: number): string; }; - - /** - * The full path of the currently running script. - */ - ScriptFullName: string; - - /** - * Forces the script to stop immediately, with an optional exit code. - */ - Quit(exitCode?: number): number; - - /** - * The Windows Script Host build version number. - */ - BuildVersion: number; - - /** - * Fully qualified path of the host executable. - */ - FullName: string; - - /** - * Gets/sets the script mode - interactive(true) or batch(false). - */ - Interactive: boolean; - - /** - * The name of the host executable (WScript.exe or CScript.exe). - */ - Name: string; - - /** - * Path of the directory containing the host executable. - */ - Path: string; - - /** - * The filename of the currently running script. - */ - ScriptName: string; - - /** - * Exposes the read-only input stream for the current script. - * Can be accessed only while using CScript.exe. - */ - StdIn: TextStreamReader; - - /** - * Windows Script Host version - */ - Version: string; - - /** - * Connects a COM object's event sources to functions named with a given prefix, in the form prefix_event. - */ - ConnectObject(objEventSource: any, strPrefix: string): void; - - /** - * Creates a COM object. - * @param strProgiID - * @param strPrefix Function names in the form prefix_event will be bound to this object's COM events. - */ - CreateObject(strProgID: string, strPrefix?: string): any; - - /** - * Disconnects a COM object from its event sources. - */ - DisconnectObject(obj: any): void; - - /** - * Retrieves an existing object with the specified ProgID from memory, or creates a new one from a file. - * @param strPathname Fully qualified path to the file containing the object persisted to disk. - * For objects in memory, pass a zero-length string. - * @param strProgID - * @param strPrefix Function names in the form prefix_event will be bound to this object's COM events. - */ - GetObject(strPathname: string, strProgID?: string, strPrefix?: string): any; - - /** - * Suspends script execution for a specified length of time, then continues execution. - * @param intTime Interval (in milliseconds) to suspend script execution. - */ - Sleep(intTime: number): void; -}; - -/** - * Allows enumerating over a COM collection, which may not have indexed item access. - */ -interface Enumerator { - /** - * Returns true if the current item is the last one in the collection, or the collection is empty, - * or the current item is undefined. - */ - atEnd(): boolean; - - /** - * Returns the current item in the collection - */ - item(): T; - - /** - * Resets the current item in the collection to the first item. If there are no items in the collection, - * the current item is set to undefined. - */ - moveFirst(): void; - - /** - * Moves the current item to the next item in the collection. If the enumerator is at the end of - * the collection or the collection is empty, the current item is set to undefined. - */ - moveNext(): void; -} - -interface EnumeratorConstructor { - new (collection: any): Enumerator; - new (collection: any): Enumerator; -} - -declare var Enumerator: EnumeratorConstructor; - -/** - * Enables reading from a COM safe array, which might have an alternate lower bound, or multiple dimensions. - */ -interface VBArray { - /** - * Returns the number of dimensions (1-based). - */ - dimensions(): number; - - /** - * Takes an index for each dimension in the array, and returns the item at the corresponding location. - */ - getItem(dimension1Index: number, ...dimensionNIndexes: number[]): T; - - /** - * Returns the smallest available index for a given dimension. - * @param dimension 1-based dimension (defaults to 1) - */ - lbound(dimension?: number): number; - - /** - * Returns the largest available index for a given dimension. - * @param dimension 1-based dimension (defaults to 1) - */ - ubound(dimension?: number): number; - - /** - * Returns a Javascript array with all the elements in the VBArray. If there are multiple dimensions, - * each successive dimension is appended to the end of the array. - * Example: [[1,2,3],[4,5,6]] becomes [1,2,3,4,5,6] - */ - toArray(): T[]; -} - -interface VBArrayConstructor { - new (safeArray: any): VBArray; - new (safeArray: any): VBArray; -} - -declare var VBArray: VBArrayConstructor; diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index 3df0e8e7d8f..d40c00371bf 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -182,6 +182,7 @@ namespace Harness.LanguageService { class NativeLanguageServiceHost extends LanguageServiceAdapterHost implements ts.LanguageServiceHost { getCompilationSettings() { return this.settings; } getCancellationToken() { return this.cancellationToken; } + getDirectories(path: string): string[] { return []; } getCurrentDirectory(): string { return ""; } getDefaultLibFileName(): string { return Harness.Compiler.defaultLibFileName; } getScriptFileNames(): string[] { return this.getFilenames(); } @@ -268,6 +269,7 @@ namespace Harness.LanguageService { getCompilationSettings(): string { return JSON.stringify(this.nativeHost.getCompilationSettings()); } getCancellationToken(): ts.HostCancellationToken { return this.nativeHost.getCancellationToken(); } getCurrentDirectory(): string { return this.nativeHost.getCurrentDirectory(); } + getDirectories(path: string) { return this.nativeHost.getDirectories(path); } getDefaultLibFileName(): string { return this.nativeHost.getDefaultLibFileName(); } getScriptFileNames(): string { return JSON.stringify(this.nativeHost.getScriptFileNames()); } getScriptSnapshot(fileName: string): ts.ScriptSnapshotShim { diff --git a/src/services/shims.ts b/src/services/shims.ts index a515f32d169..eb9c28ff7ac 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -61,6 +61,7 @@ namespace ts { getLocalizedDiagnosticMessages(): string; getCancellationToken(): HostCancellationToken; getCurrentDirectory(): string; + getDirectories(path: string): string[]; getDefaultLibFileName(options: string): string; getNewLine?(): string; getProjectVersion?(): string; @@ -400,6 +401,10 @@ namespace ts { return this.shimHost.getCurrentDirectory(); } + public getDirectories(path: string): string[] { + return this.shimHost.getDirectories(path); + } + public getDefaultLibFileName(options: CompilerOptions): string { return this.shimHost.getDefaultLibFileName(JSON.stringify(options)); }