From 7be85958a1e0a7c3253204e0723c8feccd0db3e6 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Mon, 14 May 2018 12:35:36 -0700 Subject: [PATCH 1/3] Add test for module resolution with package json containing main field referencing js file in sub directory --- ...ageRoot_mainFieldInSubDirectory.errors.txt | 14 +++++++ ...esAtPackageRoot_mainFieldInSubDirectory.js | 15 ++++++++ ...ackageRoot_mainFieldInSubDirectory.symbols | 8 ++++ ...ageRoot_mainFieldInSubDirectory.trace.json | 37 +++++++++++++++++++ ...tPackageRoot_mainFieldInSubDirectory.types | 8 ++++ ...esAtPackageRoot_mainFieldInSubDirectory.ts | 10 +++++ 6 files changed, 92 insertions(+) create mode 100644 tests/baselines/reference/moduleResolution_packageJson_yesAtPackageRoot_mainFieldInSubDirectory.errors.txt create mode 100644 tests/baselines/reference/moduleResolution_packageJson_yesAtPackageRoot_mainFieldInSubDirectory.js create mode 100644 tests/baselines/reference/moduleResolution_packageJson_yesAtPackageRoot_mainFieldInSubDirectory.symbols create mode 100644 tests/baselines/reference/moduleResolution_packageJson_yesAtPackageRoot_mainFieldInSubDirectory.trace.json create mode 100644 tests/baselines/reference/moduleResolution_packageJson_yesAtPackageRoot_mainFieldInSubDirectory.types create mode 100644 tests/cases/compiler/moduleResolution_packageJson_yesAtPackageRoot_mainFieldInSubDirectory.ts diff --git a/tests/baselines/reference/moduleResolution_packageJson_yesAtPackageRoot_mainFieldInSubDirectory.errors.txt b/tests/baselines/reference/moduleResolution_packageJson_yesAtPackageRoot_mainFieldInSubDirectory.errors.txt new file mode 100644 index 0000000000000..2dffc5530f809 --- /dev/null +++ b/tests/baselines/reference/moduleResolution_packageJson_yesAtPackageRoot_mainFieldInSubDirectory.errors.txt @@ -0,0 +1,14 @@ +/index.ts(1,19): error TS2307: Cannot find module 'foo'. + + +==== /node_modules/foo/package.json (0 errors) ==== + { "name": "foo", "version": "1.2.3", "main": "src/index.js" } + +==== /node_modules/foo/src/index.d.ts (0 errors) ==== + export const x: number; + +==== /index.ts (1 errors) ==== + import { x } from "foo"; + ~~~~~ +!!! error TS2307: Cannot find module 'foo'. + \ No newline at end of file diff --git a/tests/baselines/reference/moduleResolution_packageJson_yesAtPackageRoot_mainFieldInSubDirectory.js b/tests/baselines/reference/moduleResolution_packageJson_yesAtPackageRoot_mainFieldInSubDirectory.js new file mode 100644 index 0000000000000..1aa0a624d8dbc --- /dev/null +++ b/tests/baselines/reference/moduleResolution_packageJson_yesAtPackageRoot_mainFieldInSubDirectory.js @@ -0,0 +1,15 @@ +//// [tests/cases/compiler/moduleResolution_packageJson_yesAtPackageRoot_mainFieldInSubDirectory.ts] //// + +//// [package.json] +{ "name": "foo", "version": "1.2.3", "main": "src/index.js" } + +//// [index.d.ts] +export const x: number; + +//// [index.ts] +import { x } from "foo"; + + +//// [index.js] +"use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/moduleResolution_packageJson_yesAtPackageRoot_mainFieldInSubDirectory.symbols b/tests/baselines/reference/moduleResolution_packageJson_yesAtPackageRoot_mainFieldInSubDirectory.symbols new file mode 100644 index 0000000000000..7a5c1d7ea2788 --- /dev/null +++ b/tests/baselines/reference/moduleResolution_packageJson_yesAtPackageRoot_mainFieldInSubDirectory.symbols @@ -0,0 +1,8 @@ +=== /node_modules/foo/src/index.d.ts === +export const x: number; +>x : Symbol(x, Decl(index.d.ts, 0, 12)) + +=== /index.ts === +import { x } from "foo"; +>x : Symbol(x, Decl(index.ts, 0, 8)) + diff --git a/tests/baselines/reference/moduleResolution_packageJson_yesAtPackageRoot_mainFieldInSubDirectory.trace.json b/tests/baselines/reference/moduleResolution_packageJson_yesAtPackageRoot_mainFieldInSubDirectory.trace.json new file mode 100644 index 0000000000000..d02e83a9a70d2 --- /dev/null +++ b/tests/baselines/reference/moduleResolution_packageJson_yesAtPackageRoot_mainFieldInSubDirectory.trace.json @@ -0,0 +1,37 @@ +[ + "======== Resolving module 'foo' from '/index.ts'. ========", + "Module resolution kind is not specified, using 'NodeJs'.", + "Loading module 'foo' from 'node_modules' folder, target file type 'TypeScript'.", + "'package.json' does not have a 'typings' field.", + "'package.json' does not have a 'types' field.", + "'package.json' has 'main' field 'src/index.js' that references '/node_modules/foo/src/index.js'.", + "Found 'package.json' at '/node_modules/foo/package.json'. Package ID is 'foo/src/i.d.ts@1.2.3'.", + "File '/node_modules/foo.ts' does not exist.", + "File '/node_modules/foo.tsx' does not exist.", + "File '/node_modules/foo.d.ts' does not exist.", + "'package.json' does not have a 'typings' field.", + "'package.json' does not have a 'types' field.", + "File '/node_modules/foo/index.ts' does not exist.", + "File '/node_modules/foo/index.tsx' does not exist.", + "File '/node_modules/foo/index.d.ts' does not exist.", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Loading module 'foo' from 'node_modules' folder, target file type 'JavaScript'.", + "'package.json' does not have a 'typings' field.", + "'package.json' does not have a 'types' field.", + "'package.json' has 'main' field 'src/index.js' that references '/node_modules/foo/src/index.js'.", + "Found 'package.json' at '/node_modules/foo/package.json'. Package ID is 'foo/src/i.d.ts@1.2.3'.", + "File '/node_modules/foo.js' does not exist.", + "File '/node_modules/foo.jsx' does not exist.", + "'package.json' has 'main' field 'src/index.js' that references '/node_modules/foo/src/index.js'.", + "File '/node_modules/foo/src/index.js' does not exist.", + "Loading module as file / folder, candidate module location '/node_modules/foo/src/index.js', target file type 'JavaScript'.", + "File '/node_modules/foo/src/index.js.js' does not exist.", + "File '/node_modules/foo/src/index.js.jsx' does not exist.", + "File name '/node_modules/foo/src/index.js' has a '.js' extension - stripping it.", + "File '/node_modules/foo/src/index.js' does not exist.", + "File '/node_modules/foo/src/index.jsx' does not exist.", + "Directory '/node_modules/foo/src/index.js' does not exist, skipping all lookups in it.", + "File '/node_modules/foo/index.js' does not exist.", + "File '/node_modules/foo/index.jsx' does not exist.", + "======== Module name 'foo' was not resolved. ========" +] \ No newline at end of file diff --git a/tests/baselines/reference/moduleResolution_packageJson_yesAtPackageRoot_mainFieldInSubDirectory.types b/tests/baselines/reference/moduleResolution_packageJson_yesAtPackageRoot_mainFieldInSubDirectory.types new file mode 100644 index 0000000000000..32a66be06a6bd --- /dev/null +++ b/tests/baselines/reference/moduleResolution_packageJson_yesAtPackageRoot_mainFieldInSubDirectory.types @@ -0,0 +1,8 @@ +=== /node_modules/foo/src/index.d.ts === +export const x: number; +>x : number + +=== /index.ts === +import { x } from "foo"; +>x : any + diff --git a/tests/cases/compiler/moduleResolution_packageJson_yesAtPackageRoot_mainFieldInSubDirectory.ts b/tests/cases/compiler/moduleResolution_packageJson_yesAtPackageRoot_mainFieldInSubDirectory.ts new file mode 100644 index 0000000000000..4af56e48e1c3e --- /dev/null +++ b/tests/cases/compiler/moduleResolution_packageJson_yesAtPackageRoot_mainFieldInSubDirectory.ts @@ -0,0 +1,10 @@ +// @traceResolution: true + +// @Filename: /node_modules/foo/package.json +{ "name": "foo", "version": "1.2.3", "main": "src/index.js" } + +// @Filename: /node_modules/foo/src/index.d.ts +export const x: number; + +// @Filename: /index.ts +import { x } from "foo"; From 22d5b0e19f6de57be3545af1e8d08e469bb3d743 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Mon, 14 May 2018 13:42:45 -0700 Subject: [PATCH 2/3] Do not remove extension js or jsx from the subModuleName if the subModule doesnt have js or jsx extension --- src/compiler/moduleNameResolver.ts | 6 ++++-- ...Json_yesAtPackageRoot_mainFieldInSubDirectory.trace.json | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index 8bb65e57616d5..1da70cd173f8d 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -1012,8 +1012,10 @@ namespace ts { } else { const jsPath = tryReadPackageJsonFields(/*readTypes*/ false, packageJsonContent, nodeModuleDirectory, state); - if (typeof jsPath === "string") { - subModuleName = removeExtension(removeExtension(jsPath.substring(nodeModuleDirectory.length + 1), Extension.Js), Extension.Jsx) + Extension.Dts; + if (typeof jsPath === "string" && jsPath.length > nodeModuleDirectory.length) { + const potentialSubModule = jsPath.substring(nodeModuleDirectory.length + 1); + subModuleName = (forEach(supportedJavascriptExtensions, extension => + tryRemoveExtension(potentialSubModule, extension)) || potentialSubModule) + Extension.Dts; } else { subModuleName = "index.d.ts"; diff --git a/tests/baselines/reference/moduleResolution_packageJson_yesAtPackageRoot_mainFieldInSubDirectory.trace.json b/tests/baselines/reference/moduleResolution_packageJson_yesAtPackageRoot_mainFieldInSubDirectory.trace.json index d02e83a9a70d2..4833e4a57a010 100644 --- a/tests/baselines/reference/moduleResolution_packageJson_yesAtPackageRoot_mainFieldInSubDirectory.trace.json +++ b/tests/baselines/reference/moduleResolution_packageJson_yesAtPackageRoot_mainFieldInSubDirectory.trace.json @@ -5,7 +5,7 @@ "'package.json' does not have a 'typings' field.", "'package.json' does not have a 'types' field.", "'package.json' has 'main' field 'src/index.js' that references '/node_modules/foo/src/index.js'.", - "Found 'package.json' at '/node_modules/foo/package.json'. Package ID is 'foo/src/i.d.ts@1.2.3'.", + "Found 'package.json' at '/node_modules/foo/package.json'. Package ID is 'foo/src/index.d.ts@1.2.3'.", "File '/node_modules/foo.ts' does not exist.", "File '/node_modules/foo.tsx' does not exist.", "File '/node_modules/foo.d.ts' does not exist.", @@ -19,7 +19,7 @@ "'package.json' does not have a 'typings' field.", "'package.json' does not have a 'types' field.", "'package.json' has 'main' field 'src/index.js' that references '/node_modules/foo/src/index.js'.", - "Found 'package.json' at '/node_modules/foo/package.json'. Package ID is 'foo/src/i.d.ts@1.2.3'.", + "Found 'package.json' at '/node_modules/foo/package.json'. Package ID is 'foo/src/index.d.ts@1.2.3'.", "File '/node_modules/foo.js' does not exist.", "File '/node_modules/foo.jsx' does not exist.", "'package.json' has 'main' field 'src/index.js' that references '/node_modules/foo/src/index.js'.", From dc50fe5e40887972dba8283ca45a6e2d05c0fb85 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Mon, 14 May 2018 14:38:09 -0700 Subject: [PATCH 3/3] Apart from typing, use main field in package json to resolve typescript files Fixes #23502 --- src/compiler/moduleNameResolver.ts | 13 +++++++-- src/harness/unittests/moduleResolution.ts | 7 +++++ ...age_relativeImportWithinPackage.trace.json | 1 + ...ativeImportWithinPackage_scoped.trace.json | 1 + ...lutionWithExtensions_unexpected.trace.json | 8 +++++ ...ageRoot_mainFieldInSubDirectory.errors.txt | 14 --------- ...ageRoot_mainFieldInSubDirectory.trace.json | 29 ++++++------------- ...tPackageRoot_mainFieldInSubDirectory.types | 2 +- .../reference/packageJsonMain.trace.json | 28 ++++++++++++++++++ .../packageJsonMain_isNonRecursive.trace.json | 9 ++++++ 10 files changed, 75 insertions(+), 37 deletions(-) delete mode 100644 tests/baselines/reference/moduleResolution_packageJson_yesAtPackageRoot_mainFieldInSubDirectory.errors.txt diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index 1da70cd173f8d..510fc096297a7 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -1049,9 +1049,18 @@ namespace ts { } function loadModuleFromPackageJson(jsonContent: PackageJsonPathFields, extensions: Extensions, candidate: string, failedLookupLocations: Push, state: ModuleResolutionState): PathAndExtension | undefined { - const file = tryReadPackageJsonFields(extensions !== Extensions.JavaScript && extensions !== Extensions.Json, jsonContent, candidate, state); + let file = tryReadPackageJsonFields(extensions !== Extensions.JavaScript && extensions !== Extensions.Json, jsonContent, candidate, state); if (!file) { - return undefined; + if (extensions === Extensions.TypeScript) { + // When resolving typescript modules, try resolving using main field as well + file = tryReadPackageJsonFields(/*readTypes*/ false, jsonContent, candidate, state); + if (!file) { + return undefined; + } + } + else { + return undefined; + } } const onlyRecordFailures = !directoryProbablyExists(getDirectoryPath(file), state.host); diff --git a/src/harness/unittests/moduleResolution.ts b/src/harness/unittests/moduleResolution.ts index fc1811420d34b..b5c527aa246df 100644 --- a/src/harness/unittests/moduleResolution.ts +++ b/src/harness/unittests/moduleResolution.ts @@ -181,6 +181,13 @@ namespace ts { "/a/b/foo.ts", "/a/b/foo.tsx", "/a/b/foo.d.ts", + "/c/d", + "/c/d.ts", + "/c/d.tsx", + "/c/d.d.ts", + "/c/d/index.ts", + "/c/d/index.tsx", + "/c/d/index.d.ts", "/a/b/foo/index.ts", "/a/b/foo/index.tsx", ]); diff --git a/tests/baselines/reference/duplicatePackage_relativeImportWithinPackage.trace.json b/tests/baselines/reference/duplicatePackage_relativeImportWithinPackage.trace.json index d592022e2e177..d75683d210f83 100644 --- a/tests/baselines/reference/duplicatePackage_relativeImportWithinPackage.trace.json +++ b/tests/baselines/reference/duplicatePackage_relativeImportWithinPackage.trace.json @@ -40,6 +40,7 @@ "File '/node_modules/a/node_modules/foo.d.ts' does not exist.", "'package.json' does not have a 'typings' field.", "'package.json' does not have a 'types' field.", + "'package.json' does not have a 'main' field.", "File '/node_modules/a/node_modules/foo/index.ts' does not exist.", "File '/node_modules/a/node_modules/foo/index.tsx' does not exist.", "File '/node_modules/a/node_modules/foo/index.d.ts' exist - use it as a name resolution result.", diff --git a/tests/baselines/reference/duplicatePackage_relativeImportWithinPackage_scoped.trace.json b/tests/baselines/reference/duplicatePackage_relativeImportWithinPackage_scoped.trace.json index 108873d70f900..7b07ecd66e49d 100644 --- a/tests/baselines/reference/duplicatePackage_relativeImportWithinPackage_scoped.trace.json +++ b/tests/baselines/reference/duplicatePackage_relativeImportWithinPackage_scoped.trace.json @@ -40,6 +40,7 @@ "File '/node_modules/a/node_modules/@foo/bar.d.ts' does not exist.", "'package.json' does not have a 'typings' field.", "'package.json' does not have a 'types' field.", + "'package.json' does not have a 'main' field.", "File '/node_modules/a/node_modules/@foo/bar/index.ts' does not exist.", "File '/node_modules/a/node_modules/@foo/bar/index.tsx' does not exist.", "File '/node_modules/a/node_modules/@foo/bar/index.d.ts' exist - use it as a name resolution result.", diff --git a/tests/baselines/reference/moduleResolutionWithExtensions_unexpected.trace.json b/tests/baselines/reference/moduleResolutionWithExtensions_unexpected.trace.json index 5f32a4bf511ef..60cdab44a29fc 100644 --- a/tests/baselines/reference/moduleResolutionWithExtensions_unexpected.trace.json +++ b/tests/baselines/reference/moduleResolutionWithExtensions_unexpected.trace.json @@ -11,6 +11,14 @@ "File '/node_modules/normalize.css.d.ts' does not exist.", "'package.json' does not have a 'typings' field.", "'package.json' does not have a 'types' field.", + "'package.json' has 'main' field 'normalize.css' that references '/node_modules/normalize.css/normalize.css'.", + "File '/node_modules/normalize.css/normalize.css' exist - use it as a name resolution result.", + "File '/node_modules/normalize.css/normalize.css' has an unsupported extension, so skipping it.", + "Loading module as file / folder, candidate module location '/node_modules/normalize.css/normalize.css', target file type 'TypeScript'.", + "File '/node_modules/normalize.css/normalize.css.ts' does not exist.", + "File '/node_modules/normalize.css/normalize.css.tsx' does not exist.", + "File '/node_modules/normalize.css/normalize.css.d.ts' does not exist.", + "Directory '/node_modules/normalize.css/normalize.css' does not exist, skipping all lookups in it.", "File '/node_modules/normalize.css/index.ts' does not exist.", "File '/node_modules/normalize.css/index.tsx' does not exist.", "File '/node_modules/normalize.css/index.d.ts' does not exist.", diff --git a/tests/baselines/reference/moduleResolution_packageJson_yesAtPackageRoot_mainFieldInSubDirectory.errors.txt b/tests/baselines/reference/moduleResolution_packageJson_yesAtPackageRoot_mainFieldInSubDirectory.errors.txt deleted file mode 100644 index 2dffc5530f809..0000000000000 --- a/tests/baselines/reference/moduleResolution_packageJson_yesAtPackageRoot_mainFieldInSubDirectory.errors.txt +++ /dev/null @@ -1,14 +0,0 @@ -/index.ts(1,19): error TS2307: Cannot find module 'foo'. - - -==== /node_modules/foo/package.json (0 errors) ==== - { "name": "foo", "version": "1.2.3", "main": "src/index.js" } - -==== /node_modules/foo/src/index.d.ts (0 errors) ==== - export const x: number; - -==== /index.ts (1 errors) ==== - import { x } from "foo"; - ~~~~~ -!!! error TS2307: Cannot find module 'foo'. - \ No newline at end of file diff --git a/tests/baselines/reference/moduleResolution_packageJson_yesAtPackageRoot_mainFieldInSubDirectory.trace.json b/tests/baselines/reference/moduleResolution_packageJson_yesAtPackageRoot_mainFieldInSubDirectory.trace.json index 4833e4a57a010..849b65ee59ff6 100644 --- a/tests/baselines/reference/moduleResolution_packageJson_yesAtPackageRoot_mainFieldInSubDirectory.trace.json +++ b/tests/baselines/reference/moduleResolution_packageJson_yesAtPackageRoot_mainFieldInSubDirectory.trace.json @@ -11,27 +11,16 @@ "File '/node_modules/foo.d.ts' does not exist.", "'package.json' does not have a 'typings' field.", "'package.json' does not have a 'types' field.", - "File '/node_modules/foo/index.ts' does not exist.", - "File '/node_modules/foo/index.tsx' does not exist.", - "File '/node_modules/foo/index.d.ts' does not exist.", - "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", - "Loading module 'foo' from 'node_modules' folder, target file type 'JavaScript'.", - "'package.json' does not have a 'typings' field.", - "'package.json' does not have a 'types' field.", - "'package.json' has 'main' field 'src/index.js' that references '/node_modules/foo/src/index.js'.", - "Found 'package.json' at '/node_modules/foo/package.json'. Package ID is 'foo/src/index.d.ts@1.2.3'.", - "File '/node_modules/foo.js' does not exist.", - "File '/node_modules/foo.jsx' does not exist.", "'package.json' has 'main' field 'src/index.js' that references '/node_modules/foo/src/index.js'.", "File '/node_modules/foo/src/index.js' does not exist.", - "Loading module as file / folder, candidate module location '/node_modules/foo/src/index.js', target file type 'JavaScript'.", - "File '/node_modules/foo/src/index.js.js' does not exist.", - "File '/node_modules/foo/src/index.js.jsx' does not exist.", + "Loading module as file / folder, candidate module location '/node_modules/foo/src/index.js', target file type 'TypeScript'.", + "File '/node_modules/foo/src/index.js.ts' does not exist.", + "File '/node_modules/foo/src/index.js.tsx' does not exist.", + "File '/node_modules/foo/src/index.js.d.ts' does not exist.", "File name '/node_modules/foo/src/index.js' has a '.js' extension - stripping it.", - "File '/node_modules/foo/src/index.js' does not exist.", - "File '/node_modules/foo/src/index.jsx' does not exist.", - "Directory '/node_modules/foo/src/index.js' does not exist, skipping all lookups in it.", - "File '/node_modules/foo/index.js' does not exist.", - "File '/node_modules/foo/index.jsx' does not exist.", - "======== Module name 'foo' was not resolved. ========" + "File '/node_modules/foo/src/index.ts' does not exist.", + "File '/node_modules/foo/src/index.tsx' does not exist.", + "File '/node_modules/foo/src/index.d.ts' exist - use it as a name resolution result.", + "Resolving real path for '/node_modules/foo/src/index.d.ts', result '/node_modules/foo/src/index.d.ts'.", + "======== Module name 'foo' was successfully resolved to '/node_modules/foo/src/index.d.ts'. ========" ] \ No newline at end of file diff --git a/tests/baselines/reference/moduleResolution_packageJson_yesAtPackageRoot_mainFieldInSubDirectory.types b/tests/baselines/reference/moduleResolution_packageJson_yesAtPackageRoot_mainFieldInSubDirectory.types index 32a66be06a6bd..e0ae051e59f17 100644 --- a/tests/baselines/reference/moduleResolution_packageJson_yesAtPackageRoot_mainFieldInSubDirectory.types +++ b/tests/baselines/reference/moduleResolution_packageJson_yesAtPackageRoot_mainFieldInSubDirectory.types @@ -4,5 +4,5 @@ export const x: number; === /index.ts === import { x } from "foo"; ->x : any +>x : number diff --git a/tests/baselines/reference/packageJsonMain.trace.json b/tests/baselines/reference/packageJsonMain.trace.json index 6d39b9d4a7b7a..06c8cff66431b 100644 --- a/tests/baselines/reference/packageJsonMain.trace.json +++ b/tests/baselines/reference/packageJsonMain.trace.json @@ -11,6 +11,13 @@ "File '/node_modules/foo.d.ts' does not exist.", "'package.json' does not have a 'typings' field.", "'package.json' does not have a 'types' field.", + "'package.json' has 'main' field 'oof' that references '/node_modules/foo/oof'.", + "File '/node_modules/foo/oof' does not exist.", + "Loading module as file / folder, candidate module location '/node_modules/foo/oof', target file type 'TypeScript'.", + "File '/node_modules/foo/oof.ts' does not exist.", + "File '/node_modules/foo/oof.tsx' does not exist.", + "File '/node_modules/foo/oof.d.ts' does not exist.", + "Directory '/node_modules/foo/oof' does not exist, skipping all lookups in it.", "File '/node_modules/foo/index.ts' does not exist.", "File '/node_modules/foo/index.tsx' does not exist.", "File '/node_modules/foo/index.d.ts' does not exist.", @@ -40,6 +47,18 @@ "File '/node_modules/bar.d.ts' does not exist.", "'package.json' does not have a 'typings' field.", "'package.json' does not have a 'types' field.", + "'package.json' has 'main' field 'rab.js' that references '/node_modules/bar/rab.js'.", + "File '/node_modules/bar/rab.js' exist - use it as a name resolution result.", + "File '/node_modules/bar/rab.js' has an unsupported extension, so skipping it.", + "Loading module as file / folder, candidate module location '/node_modules/bar/rab.js', target file type 'TypeScript'.", + "File '/node_modules/bar/rab.js.ts' does not exist.", + "File '/node_modules/bar/rab.js.tsx' does not exist.", + "File '/node_modules/bar/rab.js.d.ts' does not exist.", + "File name '/node_modules/bar/rab.js' has a '.js' extension - stripping it.", + "File '/node_modules/bar/rab.ts' does not exist.", + "File '/node_modules/bar/rab.tsx' does not exist.", + "File '/node_modules/bar/rab.d.ts' does not exist.", + "Directory '/node_modules/bar/rab.js' does not exist, skipping all lookups in it.", "File '/node_modules/bar/index.ts' does not exist.", "File '/node_modules/bar/index.tsx' does not exist.", "File '/node_modules/bar/index.d.ts' does not exist.", @@ -67,6 +86,15 @@ "File '/node_modules/baz.d.ts' does not exist.", "'package.json' does not have a 'typings' field.", "'package.json' does not have a 'types' field.", + "'package.json' has 'main' field 'zab' that references '/node_modules/baz/zab'.", + "File '/node_modules/baz/zab' does not exist.", + "Loading module as file / folder, candidate module location '/node_modules/baz/zab', target file type 'TypeScript'.", + "File '/node_modules/baz/zab.ts' does not exist.", + "File '/node_modules/baz/zab.tsx' does not exist.", + "File '/node_modules/baz/zab.d.ts' does not exist.", + "File '/node_modules/baz/zab/index.ts' does not exist.", + "File '/node_modules/baz/zab/index.tsx' does not exist.", + "File '/node_modules/baz/zab/index.d.ts' does not exist.", "File '/node_modules/baz/index.ts' does not exist.", "File '/node_modules/baz/index.tsx' does not exist.", "File '/node_modules/baz/index.d.ts' does not exist.", diff --git a/tests/baselines/reference/packageJsonMain_isNonRecursive.trace.json b/tests/baselines/reference/packageJsonMain_isNonRecursive.trace.json index 81f5be11a6d76..a2878a2a4fed5 100644 --- a/tests/baselines/reference/packageJsonMain_isNonRecursive.trace.json +++ b/tests/baselines/reference/packageJsonMain_isNonRecursive.trace.json @@ -11,6 +11,15 @@ "File '/node_modules/foo.d.ts' does not exist.", "'package.json' does not have a 'typings' field.", "'package.json' does not have a 'types' field.", + "'package.json' has 'main' field 'oof' that references '/node_modules/foo/oof'.", + "File '/node_modules/foo/oof' does not exist.", + "Loading module as file / folder, candidate module location '/node_modules/foo/oof', target file type 'TypeScript'.", + "File '/node_modules/foo/oof.ts' does not exist.", + "File '/node_modules/foo/oof.tsx' does not exist.", + "File '/node_modules/foo/oof.d.ts' does not exist.", + "File '/node_modules/foo/oof/index.ts' does not exist.", + "File '/node_modules/foo/oof/index.tsx' does not exist.", + "File '/node_modules/foo/oof/index.d.ts' does not exist.", "File '/node_modules/foo/index.ts' does not exist.", "File '/node_modules/foo/index.tsx' does not exist.", "File '/node_modules/foo/index.d.ts' does not exist.",