From bfd2801a6cce22b57c99ec1cd08ab9de1c0dc763 Mon Sep 17 00:00:00 2001 From: Bill Ticehurst Date: Wed, 29 Jun 2016 08:44:06 -0700 Subject: [PATCH 1/4] Don't emit source files found under node_modules (cherry picked from commit 5f8cf1af3e4be61037cbafd698535d32d292941f) --- src/compiler/program.ts | 18 ++++++++++-------- src/compiler/utilities.ts | 8 +++----- .../moduleAugmentationInDependency2.js | 2 -- .../pathMappingBasedModuleResolution5_node.js | 3 --- 4 files changed, 13 insertions(+), 18 deletions(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index fb74f1dcaab33..5cb3b8dad7e8c 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -1097,7 +1097,7 @@ namespace ts { const modulesWithElidedImports: Map = {}; // Track source files that are JavaScript files found by searching under node_modules, as these shouldn't be compiled. - const jsFilesFoundSearchingNodeModules: Map = {}; + const sourceFilesFoundSearchingNodeModules: Map = {}; const start = new Date().getTime(); @@ -1378,7 +1378,7 @@ namespace ts { getSourceFile: program.getSourceFile, getSourceFileByPath: program.getSourceFileByPath, getSourceFiles: program.getSourceFiles, - getFilesFromNodeModules: () => jsFilesFoundSearchingNodeModules, + isSourceFileFromNodeModules: (file: SourceFile) => !!lookUp(sourceFilesFoundSearchingNodeModules, file.path), writeFile: writeFileCallback || ( (fileName, data, writeByteOrderMark, onError, sourceFiles) => host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles)), isEmitBlocked, @@ -2066,15 +2066,17 @@ namespace ts { // - noResolve is falsy // - module name comes from the list of imports // - it's not a top level JavaScript module that exceeded the search max - const isJsFileUnderNodeModules = resolution && resolution.isExternalLibraryImport && - hasJavaScriptFileExtension(resolution.resolvedFileName); + const isFromNodeModulesSearch = resolution && resolution.isExternalLibraryImport; + const isJsFileFromNodeModules = isFromNodeModulesSearch && hasJavaScriptFileExtension(resolution.resolvedFileName); - if (isJsFileUnderNodeModules) { - jsFilesFoundSearchingNodeModules[resolvedPath] = true; + if (isFromNodeModulesSearch) { + sourceFilesFoundSearchingNodeModules[resolvedPath] = true; + } + if (isJsFileFromNodeModules) { currentNodeModulesJsDepth++; } - const elideImport = isJsFileUnderNodeModules && currentNodeModulesJsDepth > maxNodeModulesJsDepth; + const elideImport = isJsFileFromNodeModules && currentNodeModulesJsDepth > maxNodeModulesJsDepth; const shouldAddFile = resolution && !options.noResolve && i < file.imports.length && !elideImport; if (elideImport) { @@ -2089,7 +2091,7 @@ namespace ts { file.imports[i].end); } - if (isJsFileUnderNodeModules) { + if (isJsFileFromNodeModules) { currentNodeModulesJsDepth--; } } diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index e8f2832cd592e..e4111e3f92563 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -36,7 +36,7 @@ namespace ts { getSourceFiles(): SourceFile[]; /* @internal */ - getFilesFromNodeModules(): Map; + isSourceFileFromNodeModules(file: SourceFile): boolean; getCommonSourceDirectory(): string; getCanonicalFileName(fileName: string): string; @@ -2277,10 +2277,9 @@ namespace ts { } else { const sourceFiles = targetSourceFile === undefined ? host.getSourceFiles() : [targetSourceFile]; - const nodeModulesFiles = host.getFilesFromNodeModules(); for (const sourceFile of sourceFiles) { // Don't emit if source file is a declaration file, or was located under node_modules - if (!isDeclarationFile(sourceFile) && !lookUp(nodeModulesFiles, sourceFile.path)) { + if (!isDeclarationFile(sourceFile) && !host.isSourceFileFromNodeModules(sourceFile)) { onSingleFileEmit(host, sourceFile); } } @@ -2314,10 +2313,9 @@ namespace ts { function onBundledEmit(host: EmitHost) { // Can emit only sources that are not declaration file and are either non module code or module with // --module or --target es6 specified. Files included by searching under node_modules are also not emitted. - const nodeModulesFiles = host.getFilesFromNodeModules(); const bundledSources = filter(host.getSourceFiles(), sourceFile => !isDeclarationFile(sourceFile) && - !lookUp(nodeModulesFiles, sourceFile.path) && + !host.isSourceFileFromNodeModules(sourceFile) && (!isExternalModule(sourceFile) || !!getEmitModuleKind(options))); if (bundledSources.length) { diff --git a/tests/baselines/reference/moduleAugmentationInDependency2.js b/tests/baselines/reference/moduleAugmentationInDependency2.js index 381f1e72d8f31..0a5d83695a34f 100644 --- a/tests/baselines/reference/moduleAugmentationInDependency2.js +++ b/tests/baselines/reference/moduleAugmentationInDependency2.js @@ -8,8 +8,6 @@ export {}; //// [app.ts] import "A" -//// [index.js] -"use strict"; //// [app.js] "use strict"; require("A"); diff --git a/tests/baselines/reference/pathMappingBasedModuleResolution5_node.js b/tests/baselines/reference/pathMappingBasedModuleResolution5_node.js index 1958800f91893..e4440299cc75c 100644 --- a/tests/baselines/reference/pathMappingBasedModuleResolution5_node.js +++ b/tests/baselines/reference/pathMappingBasedModuleResolution5_node.js @@ -31,9 +31,6 @@ exports.x = 1; //// [file2.js] "use strict"; exports.y = 1; -//// [file4.js] -"use strict"; -exports.z1 = 1; //// [file1.js] "use strict"; var file1_1 = require("folder2/file1"); From d93e0a6ebc73e728c26fdc027d5713e3df181510 Mon Sep 17 00:00:00 2001 From: Bill Ticehurst Date: Wed, 29 Jun 2016 17:04:42 -0700 Subject: [PATCH 2/4] Dont load JavaScript if types packages are present (cherry picked from commit 5a45c44eb789f52ceb1aa0e23a230ecb599bfb08) --- src/compiler/program.ts | 19 ++++++++++++------- .../amd/maxDepthIncreased/root.js | 6 ++++-- .../nodeModulesMaxDepthIncreased.errors.txt | 18 +++++++++++++++--- .../amd/nodeModulesMaxDepthIncreased.json | 1 + .../node/maxDepthIncreased/root.js | 5 ++++- .../nodeModulesMaxDepthIncreased.errors.txt | 18 +++++++++++++++--- .../node/nodeModulesMaxDepthIncreased.json | 1 + .../node_modules/@types/m4/entry.d.ts | 1 + .../node_modules/@types/m4/package.json | 5 +++++ .../node_modules/m4/entry.js | 1 + .../node_modules/m4/package.json | 5 +++++ .../maxDepthIncreased/root.ts | 8 +++++++- 12 files changed, 71 insertions(+), 17 deletions(-) create mode 100644 tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/@types/m4/entry.d.ts create mode 100644 tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/@types/m4/package.json create mode 100644 tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/m4/entry.js create mode 100644 tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/m4/package.json diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 5cb3b8dad7e8c..c56debdf251c5 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -779,13 +779,18 @@ namespace ts { while (true) { const baseName = getBaseFileName(directory); if (baseName !== "node_modules") { - const result = - // first: try to load module as-is - loadModuleFromNodeModulesFolder(moduleName, directory, failedLookupLocations, state) || - // second: try to load module from the scope '@types' - loadModuleFromNodeModulesFolder(combinePaths("@types", moduleName), directory, failedLookupLocations, state); - if (result) { - return result; + // Try to load source from the package + const packageResult = loadModuleFromNodeModulesFolder(moduleName, directory, failedLookupLocations, state); + if (packageResult && hasTypeScriptFileExtension(packageResult)) { + // Always prefer a TypeScript (.ts, .tsx, .d.ts) file shipped with the package + return packageResult; + } + else { + // Else prefer a types package over non-TypeScript results (e.g. JavaScript files) + const typesResult = loadModuleFromNodeModulesFolder(combinePaths("@types", moduleName), directory, failedLookupLocations, state); + if (typesResult || packageResult) { + return typesResult || packageResult; + } } } diff --git a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/maxDepthIncreased/root.js b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/maxDepthIncreased/root.js index 77951a4889da7..0024891fbe320 100644 --- a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/maxDepthIncreased/root.js +++ b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/maxDepthIncreased/root.js @@ -1,6 +1,8 @@ -define(["require", "exports", "m1"], function (require, exports, m1) { +define(["require", "exports", "m1", "m4"], function (require, exports, m1, m4) { "use strict"; m1.f1("test"); m1.f2.a = 10; - m1.f2.person.age = "10"; // Error: Should be number + m1.f2.person.age = "10"; // Should error if loaded the .js files correctly + var r1 = m4.test.charAt(2); // Should error if correctly not using the .js file but using @types info + var r2 = 3 + m4.foo; // Should be OK if correctly using the @types .d.ts file }); diff --git a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/nodeModulesMaxDepthIncreased.errors.txt b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/nodeModulesMaxDepthIncreased.errors.txt index f63c2a789e8c4..473d69bc526ad 100644 --- a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/nodeModulesMaxDepthIncreased.errors.txt +++ b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/nodeModulesMaxDepthIncreased.errors.txt @@ -1,4 +1,5 @@ -maxDepthIncreased/root.ts(4,1): error TS2322: Type 'string' is not assignable to type 'number'. +maxDepthIncreased/root.ts(7,1): error TS2322: Type 'string' is not assignable to type 'number'. +maxDepthIncreased/root.ts(8,13): error TS2339: Property 'test' does not exist on type 'typeof "C:/src/TypeScript/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/@...'. ==== index.js (0 errors) ==== @@ -28,11 +29,22 @@ maxDepthIncreased/root.ts(4,1): error TS2322: Type 'string' is not assignable to exports.f2 = m2; -==== maxDepthIncreased/root.ts (1 errors) ==== +==== entry.d.ts (0 errors) ==== + export declare var foo: number; + +==== maxDepthIncreased/root.ts (2 errors) ==== import * as m1 from "m1"; + import * as m4 from "m4"; + m1.f1("test"); m1.f2.a = 10; - m1.f2.person.age = "10"; // Error: Should be number + + m1.f2.person.age = "10"; // Should error if loaded the .js files correctly ~~~~~~~~~~~~~~~~ !!! error TS2322: Type 'string' is not assignable to type 'number'. + let r1 = m4.test.charAt(2); // Should error if correctly not using the .js file but using @types info + ~~~~ +!!! error TS2339: Property 'test' does not exist on type 'typeof "C:/src/TypeScript/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/@...'. + + let r2 = 3 + m4.foo; // Should be OK if correctly using the @types .d.ts file \ No newline at end of file diff --git a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/nodeModulesMaxDepthIncreased.json b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/nodeModulesMaxDepthIncreased.json index 1350bf6441e25..bb3234f1db227 100644 --- a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/nodeModulesMaxDepthIncreased.json +++ b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/nodeModulesMaxDepthIncreased.json @@ -10,6 +10,7 @@ "maxDepthIncreased/node_modules/m2/node_modules/m3/index.js", "maxDepthIncreased/node_modules/m2/entry.js", "maxDepthIncreased/node_modules/m1/index.js", + "maxDepthIncreased/node_modules/@types/m4/entry.d.ts", "maxDepthIncreased/root.ts" ], "emittedFiles": [ diff --git a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/maxDepthIncreased/root.js b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/maxDepthIncreased/root.js index 3a0a96991b058..ba6d7e96241a7 100644 --- a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/maxDepthIncreased/root.js +++ b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/maxDepthIncreased/root.js @@ -1,5 +1,8 @@ "use strict"; var m1 = require("m1"); +var m4 = require("m4"); m1.f1("test"); m1.f2.a = 10; -m1.f2.person.age = "10"; // Error: Should be number +m1.f2.person.age = "10"; // Should error if loaded the .js files correctly +var r1 = m4.test.charAt(2); // Should error if correctly not using the .js file but using @types info +var r2 = 3 + m4.foo; // Should be OK if correctly using the @types .d.ts file diff --git a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/nodeModulesMaxDepthIncreased.errors.txt b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/nodeModulesMaxDepthIncreased.errors.txt index f63c2a789e8c4..473d69bc526ad 100644 --- a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/nodeModulesMaxDepthIncreased.errors.txt +++ b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/nodeModulesMaxDepthIncreased.errors.txt @@ -1,4 +1,5 @@ -maxDepthIncreased/root.ts(4,1): error TS2322: Type 'string' is not assignable to type 'number'. +maxDepthIncreased/root.ts(7,1): error TS2322: Type 'string' is not assignable to type 'number'. +maxDepthIncreased/root.ts(8,13): error TS2339: Property 'test' does not exist on type 'typeof "C:/src/TypeScript/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/@...'. ==== index.js (0 errors) ==== @@ -28,11 +29,22 @@ maxDepthIncreased/root.ts(4,1): error TS2322: Type 'string' is not assignable to exports.f2 = m2; -==== maxDepthIncreased/root.ts (1 errors) ==== +==== entry.d.ts (0 errors) ==== + export declare var foo: number; + +==== maxDepthIncreased/root.ts (2 errors) ==== import * as m1 from "m1"; + import * as m4 from "m4"; + m1.f1("test"); m1.f2.a = 10; - m1.f2.person.age = "10"; // Error: Should be number + + m1.f2.person.age = "10"; // Should error if loaded the .js files correctly ~~~~~~~~~~~~~~~~ !!! error TS2322: Type 'string' is not assignable to type 'number'. + let r1 = m4.test.charAt(2); // Should error if correctly not using the .js file but using @types info + ~~~~ +!!! error TS2339: Property 'test' does not exist on type 'typeof "C:/src/TypeScript/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/@...'. + + let r2 = 3 + m4.foo; // Should be OK if correctly using the @types .d.ts file \ No newline at end of file diff --git a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/nodeModulesMaxDepthIncreased.json b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/nodeModulesMaxDepthIncreased.json index 1350bf6441e25..bb3234f1db227 100644 --- a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/nodeModulesMaxDepthIncreased.json +++ b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/nodeModulesMaxDepthIncreased.json @@ -10,6 +10,7 @@ "maxDepthIncreased/node_modules/m2/node_modules/m3/index.js", "maxDepthIncreased/node_modules/m2/entry.js", "maxDepthIncreased/node_modules/m1/index.js", + "maxDepthIncreased/node_modules/@types/m4/entry.d.ts", "maxDepthIncreased/root.ts" ], "emittedFiles": [ diff --git a/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/@types/m4/entry.d.ts b/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/@types/m4/entry.d.ts new file mode 100644 index 0000000000000..f0fc245910a1a --- /dev/null +++ b/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/@types/m4/entry.d.ts @@ -0,0 +1 @@ +export declare var foo: number; diff --git a/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/@types/m4/package.json b/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/@types/m4/package.json new file mode 100644 index 0000000000000..53ac1558a23ce --- /dev/null +++ b/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/@types/m4/package.json @@ -0,0 +1,5 @@ +{ + "types": "entry.d.ts", + "name": "m4", + "version": "1.0.0" +} \ No newline at end of file diff --git a/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/m4/entry.js b/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/m4/entry.js new file mode 100644 index 0000000000000..a1cb557b18d8a --- /dev/null +++ b/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/m4/entry.js @@ -0,0 +1 @@ +exports.test = "hello, world"; diff --git a/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/m4/package.json b/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/m4/package.json new file mode 100644 index 0000000000000..4ae99f312fc0f --- /dev/null +++ b/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/m4/package.json @@ -0,0 +1,5 @@ +{ + "name": "m4", + "version": "1.0.0", + "main": "entry.js" +} \ No newline at end of file diff --git a/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/root.ts b/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/root.ts index 9ed943bebba36..5d9f331b2492a 100644 --- a/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/root.ts +++ b/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/root.ts @@ -1,4 +1,10 @@ import * as m1 from "m1"; +import * as m4 from "m4"; + m1.f1("test"); m1.f2.a = 10; -m1.f2.person.age = "10"; // Error: Should be number + +m1.f2.person.age = "10"; // Should error if loaded the .js files correctly +let r1 = m4.test.charAt(2); // Should error if correctly not using the .js file but using @types info + +let r2 = 3 + m4.foo; // Should be OK if correctly using the @types .d.ts file From 5a4cd8394007d8d77d2c09ae3d676a63d0b6e441 Mon Sep 17 00:00:00 2001 From: Bill Ticehurst Date: Wed, 29 Jun 2016 17:05:55 -0700 Subject: [PATCH 3/4] Renamed API (cherry picked from commit d8047b607f11cdf319284bb344282582c7c0aea0) --- src/compiler/program.ts | 2 +- src/compiler/utilities.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index c56debdf251c5..2e4492efa7b14 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -1383,7 +1383,7 @@ namespace ts { getSourceFile: program.getSourceFile, getSourceFileByPath: program.getSourceFileByPath, getSourceFiles: program.getSourceFiles, - isSourceFileFromNodeModules: (file: SourceFile) => !!lookUp(sourceFilesFoundSearchingNodeModules, file.path), + isSourceFileFromExternalLibrary: (file: SourceFile) => !!lookUp(sourceFilesFoundSearchingNodeModules, file.path), writeFile: writeFileCallback || ( (fileName, data, writeByteOrderMark, onError, sourceFiles) => host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles)), isEmitBlocked, diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index e4111e3f92563..7892af6624f3c 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -36,7 +36,7 @@ namespace ts { getSourceFiles(): SourceFile[]; /* @internal */ - isSourceFileFromNodeModules(file: SourceFile): boolean; + isSourceFileFromExternalLibrary(file: SourceFile): boolean; getCommonSourceDirectory(): string; getCanonicalFileName(fileName: string): string; @@ -2279,7 +2279,7 @@ namespace ts { const sourceFiles = targetSourceFile === undefined ? host.getSourceFiles() : [targetSourceFile]; for (const sourceFile of sourceFiles) { // Don't emit if source file is a declaration file, or was located under node_modules - if (!isDeclarationFile(sourceFile) && !host.isSourceFileFromNodeModules(sourceFile)) { + if (!isDeclarationFile(sourceFile) && !host.isSourceFileFromExternalLibrary(sourceFile)) { onSingleFileEmit(host, sourceFile); } } @@ -2315,7 +2315,7 @@ namespace ts { // --module or --target es6 specified. Files included by searching under node_modules are also not emitted. const bundledSources = filter(host.getSourceFiles(), sourceFile => !isDeclarationFile(sourceFile) && - !host.isSourceFileFromNodeModules(sourceFile) && + !host.isSourceFileFromExternalLibrary(sourceFile) && (!isExternalModule(sourceFile) || !!getEmitModuleKind(options))); if (bundledSources.length) { From 2dc84a8c4b5ecdb09fea7acc2c3bfa2712e741de Mon Sep 17 00:00:00 2001 From: Bill Ticehurst Date: Thu, 30 Jun 2016 16:36:39 -0700 Subject: [PATCH 4/4] Removed one error to avoid full path issues (cherry picked from commit 5e4f13f342a75ec8f7cf65cb669bec9d6e6c5581) --- .../amd/maxDepthIncreased/root.js | 1 - .../amd/nodeModulesMaxDepthIncreased.errors.txt | 6 +----- .../node/maxDepthIncreased/root.js | 1 - .../node/nodeModulesMaxDepthIncreased.errors.txt | 6 +----- .../projects/NodeModulesSearch/maxDepthIncreased/root.ts | 1 - 5 files changed, 2 insertions(+), 13 deletions(-) diff --git a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/maxDepthIncreased/root.js b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/maxDepthIncreased/root.js index 0024891fbe320..9ef3915c85125 100644 --- a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/maxDepthIncreased/root.js +++ b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/maxDepthIncreased/root.js @@ -3,6 +3,5 @@ define(["require", "exports", "m1", "m4"], function (require, exports, m1, m4) { m1.f1("test"); m1.f2.a = 10; m1.f2.person.age = "10"; // Should error if loaded the .js files correctly - var r1 = m4.test.charAt(2); // Should error if correctly not using the .js file but using @types info var r2 = 3 + m4.foo; // Should be OK if correctly using the @types .d.ts file }); diff --git a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/nodeModulesMaxDepthIncreased.errors.txt b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/nodeModulesMaxDepthIncreased.errors.txt index 473d69bc526ad..f511000d5ac4a 100644 --- a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/nodeModulesMaxDepthIncreased.errors.txt +++ b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/nodeModulesMaxDepthIncreased.errors.txt @@ -1,5 +1,4 @@ maxDepthIncreased/root.ts(7,1): error TS2322: Type 'string' is not assignable to type 'number'. -maxDepthIncreased/root.ts(8,13): error TS2339: Property 'test' does not exist on type 'typeof "C:/src/TypeScript/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/@...'. ==== index.js (0 errors) ==== @@ -32,7 +31,7 @@ maxDepthIncreased/root.ts(8,13): error TS2339: Property 'test' does not exist on ==== entry.d.ts (0 errors) ==== export declare var foo: number; -==== maxDepthIncreased/root.ts (2 errors) ==== +==== maxDepthIncreased/root.ts (1 errors) ==== import * as m1 from "m1"; import * as m4 from "m4"; @@ -42,9 +41,6 @@ maxDepthIncreased/root.ts(8,13): error TS2339: Property 'test' does not exist on m1.f2.person.age = "10"; // Should error if loaded the .js files correctly ~~~~~~~~~~~~~~~~ !!! error TS2322: Type 'string' is not assignable to type 'number'. - let r1 = m4.test.charAt(2); // Should error if correctly not using the .js file but using @types info - ~~~~ -!!! error TS2339: Property 'test' does not exist on type 'typeof "C:/src/TypeScript/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/@...'. let r2 = 3 + m4.foo; // Should be OK if correctly using the @types .d.ts file \ No newline at end of file diff --git a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/maxDepthIncreased/root.js b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/maxDepthIncreased/root.js index ba6d7e96241a7..f6783cda79b04 100644 --- a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/maxDepthIncreased/root.js +++ b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/maxDepthIncreased/root.js @@ -4,5 +4,4 @@ var m4 = require("m4"); m1.f1("test"); m1.f2.a = 10; m1.f2.person.age = "10"; // Should error if loaded the .js files correctly -var r1 = m4.test.charAt(2); // Should error if correctly not using the .js file but using @types info var r2 = 3 + m4.foo; // Should be OK if correctly using the @types .d.ts file diff --git a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/nodeModulesMaxDepthIncreased.errors.txt b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/nodeModulesMaxDepthIncreased.errors.txt index 473d69bc526ad..f511000d5ac4a 100644 --- a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/nodeModulesMaxDepthIncreased.errors.txt +++ b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/nodeModulesMaxDepthIncreased.errors.txt @@ -1,5 +1,4 @@ maxDepthIncreased/root.ts(7,1): error TS2322: Type 'string' is not assignable to type 'number'. -maxDepthIncreased/root.ts(8,13): error TS2339: Property 'test' does not exist on type 'typeof "C:/src/TypeScript/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/@...'. ==== index.js (0 errors) ==== @@ -32,7 +31,7 @@ maxDepthIncreased/root.ts(8,13): error TS2339: Property 'test' does not exist on ==== entry.d.ts (0 errors) ==== export declare var foo: number; -==== maxDepthIncreased/root.ts (2 errors) ==== +==== maxDepthIncreased/root.ts (1 errors) ==== import * as m1 from "m1"; import * as m4 from "m4"; @@ -42,9 +41,6 @@ maxDepthIncreased/root.ts(8,13): error TS2339: Property 'test' does not exist on m1.f2.person.age = "10"; // Should error if loaded the .js files correctly ~~~~~~~~~~~~~~~~ !!! error TS2322: Type 'string' is not assignable to type 'number'. - let r1 = m4.test.charAt(2); // Should error if correctly not using the .js file but using @types info - ~~~~ -!!! error TS2339: Property 'test' does not exist on type 'typeof "C:/src/TypeScript/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/node_modules/@...'. let r2 = 3 + m4.foo; // Should be OK if correctly using the @types .d.ts file \ No newline at end of file diff --git a/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/root.ts b/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/root.ts index 5d9f331b2492a..2b80564ae26b9 100644 --- a/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/root.ts +++ b/tests/cases/projects/NodeModulesSearch/maxDepthIncreased/root.ts @@ -5,6 +5,5 @@ m1.f1("test"); m1.f2.a = 10; m1.f2.person.age = "10"; // Should error if loaded the .js files correctly -let r1 = m4.test.charAt(2); // Should error if correctly not using the .js file but using @types info let r2 = 3 + m4.foo; // Should be OK if correctly using the @types .d.ts file