From 26fdc3d0c170be5b3e80251d761fe27f06857e5d Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Fri, 11 Feb 2022 09:46:53 -0800 Subject: [PATCH] Correctly resolve imports ending with "." and ".." --- src/compiler/moduleNameResolver.ts | 18 +++++++++++-- src/compiler/path.ts | 12 --------- .../reference/importFromDot.errors.txt | 14 ++++++++++ tests/baselines/reference/importFromDot.js | 25 ++++++++++++++++++ .../baselines/reference/importFromDot.symbols | 13 ++++++++++ tests/baselines/reference/importFromDot.types | 15 +++++++++++ .../importWithTrailingSlash.errors.txt | 26 +++++++++++++++++++ .../reference/importWithTrailingSlash.symbols | 4 --- .../importWithTrailingSlash.trace.json | 16 +++++++----- .../reference/importWithTrailingSlash.types | 16 ++++++------ ...-are-disabled-and-a-decl-map-is-missing.js | 2 -- ...-are-disabled-and-a-decl-map-is-present.js | 2 -- ...s-are-enabled-and-a-decl-map-is-missing.js | 2 -- ...s-are-enabled-and-a-decl-map-is-present.js | 2 -- ...-are-disabled-and-a-decl-map-is-missing.js | 2 -- ...-are-disabled-and-a-decl-map-is-present.js | 2 -- ...s-are-enabled-and-a-decl-map-is-missing.js | 2 -- ...s-are-enabled-and-a-decl-map-is-present.js | 2 -- ...-are-disabled-and-a-decl-map-is-present.js | 2 -- ...s-are-enabled-and-a-decl-map-is-missing.js | 2 -- ...s-are-enabled-and-a-decl-map-is-present.js | 2 -- .../moduleResolution/importFromDot.ts | 10 +++++++ 22 files changed, 136 insertions(+), 55 deletions(-) create mode 100644 tests/baselines/reference/importFromDot.errors.txt create mode 100644 tests/baselines/reference/importFromDot.js create mode 100644 tests/baselines/reference/importFromDot.symbols create mode 100644 tests/baselines/reference/importFromDot.types create mode 100644 tests/baselines/reference/importWithTrailingSlash.errors.txt create mode 100644 tests/cases/conformance/moduleResolution/importFromDot.ts diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index 5ea72a6bbf2d8..7d6d0f67d7aee 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -417,7 +417,7 @@ namespace ts { result = searchResult && searchResult.value; } else { - const { path: candidate } = normalizePathAndParts(combinePaths(initialLocationForSecondaryLookup, typeReferenceDirectiveName)); + const { path: candidate } = normalizePathForCJSResolution(initialLocationForSecondaryLookup, typeReferenceDirectiveName); result = nodeLoadModuleByRelativeName(Extensions.DtsOnly, candidate, /*onlyRecordFailures*/ false, moduleResolutionState, /*considerPackageJson*/ true); } return resolvedTypeScriptOnly(result); @@ -1329,12 +1329,26 @@ namespace ts { return { value: resolvedValue && { resolved: resolvedValue, isExternalLibraryImport: true } }; } else { - const { path: candidate, parts } = normalizePathAndParts(combinePaths(containingDirectory, moduleName)); + const { path: candidate, parts } = normalizePathForCJSResolution(containingDirectory, moduleName); const resolved = nodeLoadModuleByRelativeName(extensions, candidate, /*onlyRecordFailures*/ false, state, /*considerPackageJson*/ true); // Treat explicit "node_modules" import as an external library import. return resolved && toSearchResult({ resolved, isExternalLibraryImport: contains(parts, "node_modules") }); } } + + } + + // If you import from "." inside a containing directory "/foo", the result of `normalizePath` + // would be "/foo", but this loses the information that `foo` is a directory and we intended + // to look inside of it. The Node CommonJS resolution algorithm doesn't call this out + // (https://nodejs.org/api/modules.html#all-together), but it seems that module paths ending + // in `.` are actually normalized to `./` before proceeding with the resolution algorithm. + function normalizePathForCJSResolution(containingDirectory: string, moduleName: string) { + const combined = combinePaths(containingDirectory, moduleName); + const parts = getPathComponents(combined); + const lastPart = lastOrUndefined(parts); + const path = lastPart === "." || lastPart === ".." ? ensureTrailingDirectorySeparator(normalizePath(combined)) : normalizePath(combined); + return { path, parts }; } function realPath(path: string, host: ModuleResolutionHost, traceEnabled: boolean): string { diff --git a/src/compiler/path.ts b/src/compiler/path.ts index d09108d34c7f3..ebc837feb33a3 100644 --- a/src/compiler/path.ts +++ b/src/compiler/path.ts @@ -585,18 +585,6 @@ namespace ts { return getCanonicalFileName(nonCanonicalizedPath) as Path; } - export function normalizePathAndParts(path: string): { path: string, parts: string[] } { - path = normalizeSlashes(path); - const [root, ...parts] = reducePathComponents(getPathComponents(path)); - if (parts.length) { - const joinedParts = root + parts.join(directorySeparator); - return { path: hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(joinedParts) : joinedParts, parts }; - } - else { - return { path: root, parts }; - } - } - //// Path Mutation /** diff --git a/tests/baselines/reference/importFromDot.errors.txt b/tests/baselines/reference/importFromDot.errors.txt new file mode 100644 index 0000000000000..567c61451d9f5 --- /dev/null +++ b/tests/baselines/reference/importFromDot.errors.txt @@ -0,0 +1,14 @@ +tests/cases/conformance/moduleResolution/a/b.ts(1,20): error TS2305: Module '"."' has no exported member 'rootA'. + + +==== tests/cases/conformance/moduleResolution/a.ts (0 errors) ==== + export const rootA = 0; + +==== tests/cases/conformance/moduleResolution/a/index.ts (0 errors) ==== + export const indexInA = 0; + +==== tests/cases/conformance/moduleResolution/a/b.ts (1 errors) ==== + import { indexInA, rootA } from "."; + ~~~~~ +!!! error TS2305: Module '"."' has no exported member 'rootA'. + \ No newline at end of file diff --git a/tests/baselines/reference/importFromDot.js b/tests/baselines/reference/importFromDot.js new file mode 100644 index 0000000000000..0bccb84eeb2ad --- /dev/null +++ b/tests/baselines/reference/importFromDot.js @@ -0,0 +1,25 @@ +//// [tests/cases/conformance/moduleResolution/importFromDot.ts] //// + +//// [a.ts] +export const rootA = 0; + +//// [index.ts] +export const indexInA = 0; + +//// [b.ts] +import { indexInA, rootA } from "."; + + +//// [a.js] +"use strict"; +exports.__esModule = true; +exports.rootA = void 0; +exports.rootA = 0; +//// [index.js] +"use strict"; +exports.__esModule = true; +exports.indexInA = void 0; +exports.indexInA = 0; +//// [b.js] +"use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/importFromDot.symbols b/tests/baselines/reference/importFromDot.symbols new file mode 100644 index 0000000000000..2431f381a341c --- /dev/null +++ b/tests/baselines/reference/importFromDot.symbols @@ -0,0 +1,13 @@ +=== tests/cases/conformance/moduleResolution/a.ts === +export const rootA = 0; +>rootA : Symbol(rootA, Decl(a.ts, 0, 12)) + +=== tests/cases/conformance/moduleResolution/a/index.ts === +export const indexInA = 0; +>indexInA : Symbol(indexInA, Decl(index.ts, 0, 12)) + +=== tests/cases/conformance/moduleResolution/a/b.ts === +import { indexInA, rootA } from "."; +>indexInA : Symbol(indexInA, Decl(b.ts, 0, 8)) +>rootA : Symbol(rootA, Decl(b.ts, 0, 18)) + diff --git a/tests/baselines/reference/importFromDot.types b/tests/baselines/reference/importFromDot.types new file mode 100644 index 0000000000000..f595b92a9961e --- /dev/null +++ b/tests/baselines/reference/importFromDot.types @@ -0,0 +1,15 @@ +=== tests/cases/conformance/moduleResolution/a.ts === +export const rootA = 0; +>rootA : 0 +>0 : 0 + +=== tests/cases/conformance/moduleResolution/a/index.ts === +export const indexInA = 0; +>indexInA : 0 +>0 : 0 + +=== tests/cases/conformance/moduleResolution/a/b.ts === +import { indexInA, rootA } from "."; +>indexInA : 0 +>rootA : any + diff --git a/tests/baselines/reference/importWithTrailingSlash.errors.txt b/tests/baselines/reference/importWithTrailingSlash.errors.txt new file mode 100644 index 0000000000000..60125b35a5847 --- /dev/null +++ b/tests/baselines/reference/importWithTrailingSlash.errors.txt @@ -0,0 +1,26 @@ +/a/b/test.ts(3,3): error TS2339: Property 'a' does not exist on type '{ aIndex: number; }'. +/a/test.ts(3,3): error TS2339: Property 'a' does not exist on type '{ aIndex: number; }'. + + +==== /a.ts (0 errors) ==== + export default { a: 0 }; + +==== /a/index.ts (0 errors) ==== + export default { aIndex: 0 }; + +==== /a/test.ts (1 errors) ==== + import a from "."; + import aIndex from "./"; + a.a; + ~ +!!! error TS2339: Property 'a' does not exist on type '{ aIndex: number; }'. + aIndex.aIndex; + +==== /a/b/test.ts (1 errors) ==== + import a from ".."; + import aIndex from "../"; + a.a; + ~ +!!! error TS2339: Property 'a' does not exist on type '{ aIndex: number; }'. + aIndex.aIndex; + \ No newline at end of file diff --git a/tests/baselines/reference/importWithTrailingSlash.symbols b/tests/baselines/reference/importWithTrailingSlash.symbols index c6c4946438010..ddaf5befb066e 100644 --- a/tests/baselines/reference/importWithTrailingSlash.symbols +++ b/tests/baselines/reference/importWithTrailingSlash.symbols @@ -14,9 +14,7 @@ import aIndex from "./"; >aIndex : Symbol(aIndex, Decl(test.ts, 1, 6)) a.a; ->a.a : Symbol(a, Decl(a.ts, 0, 16)) >a : Symbol(a, Decl(test.ts, 0, 6)) ->a : Symbol(a, Decl(a.ts, 0, 16)) aIndex.aIndex; >aIndex.aIndex : Symbol(aIndex, Decl(index.ts, 0, 16)) @@ -31,9 +29,7 @@ import aIndex from "../"; >aIndex : Symbol(aIndex, Decl(test.ts, 1, 6)) a.a; ->a.a : Symbol(a, Decl(a.ts, 0, 16)) >a : Symbol(a, Decl(test.ts, 0, 6)) ->a : Symbol(a, Decl(a.ts, 0, 16)) aIndex.aIndex; >aIndex.aIndex : Symbol(aIndex, Decl(index.ts, 0, 16)) diff --git a/tests/baselines/reference/importWithTrailingSlash.trace.json b/tests/baselines/reference/importWithTrailingSlash.trace.json index fb77f85298840..b60d3bc6aab90 100644 --- a/tests/baselines/reference/importWithTrailingSlash.trace.json +++ b/tests/baselines/reference/importWithTrailingSlash.trace.json @@ -1,20 +1,22 @@ [ "======== Resolving module '.' from '/a/test.ts'. ========", "Explicitly specified module resolution kind: 'NodeJs'.", - "Loading module as file / folder, candidate module location '/a', target file type 'TypeScript'.", - "File '/a.ts' exist - use it as a name resolution result.", - "======== Module name '.' was successfully resolved to '/a.ts'. ========", + "Loading module as file / folder, candidate module location '/a/', target file type 'TypeScript'.", + "File '/a/package.json' does not exist.", + "File '/a/index.ts' exist - use it as a name resolution result.", + "======== Module name '.' was successfully resolved to '/a/index.ts'. ========", "======== Resolving module './' from '/a/test.ts'. ========", "Explicitly specified module resolution kind: 'NodeJs'.", "Loading module as file / folder, candidate module location '/a/', target file type 'TypeScript'.", - "File '/a/package.json' does not exist.", + "File '/a/package.json' does not exist according to earlier cached lookups.", "File '/a/index.ts' exist - use it as a name resolution result.", "======== Module name './' was successfully resolved to '/a/index.ts'. ========", "======== Resolving module '..' from '/a/b/test.ts'. ========", "Explicitly specified module resolution kind: 'NodeJs'.", - "Loading module as file / folder, candidate module location '/a', target file type 'TypeScript'.", - "File '/a.ts' exist - use it as a name resolution result.", - "======== Module name '..' was successfully resolved to '/a.ts'. ========", + "Loading module as file / folder, candidate module location '/a/', target file type 'TypeScript'.", + "File '/a/package.json' does not exist according to earlier cached lookups.", + "File '/a/index.ts' exist - use it as a name resolution result.", + "======== Module name '..' was successfully resolved to '/a/index.ts'. ========", "======== Resolving module '../' from '/a/b/test.ts'. ========", "Explicitly specified module resolution kind: 'NodeJs'.", "Loading module as file / folder, candidate module location '/a/', target file type 'TypeScript'.", diff --git a/tests/baselines/reference/importWithTrailingSlash.types b/tests/baselines/reference/importWithTrailingSlash.types index beec18ea4aad9..41c2a160afa40 100644 --- a/tests/baselines/reference/importWithTrailingSlash.types +++ b/tests/baselines/reference/importWithTrailingSlash.types @@ -12,15 +12,15 @@ export default { aIndex: 0 }; === /a/test.ts === import a from "."; ->a : { a: number; } +>a : { aIndex: number; } import aIndex from "./"; >aIndex : { aIndex: number; } a.a; ->a.a : number ->a : { a: number; } ->a : number +>a.a : any +>a : { aIndex: number; } +>a : any aIndex.aIndex; >aIndex.aIndex : number @@ -29,15 +29,15 @@ aIndex.aIndex; === /a/b/test.ts === import a from ".."; ->a : { a: number; } +>a : { aIndex: number; } import aIndex from "../"; >aIndex : { aIndex: number; } a.a; ->a.a : number ->a : { a: number; } ->a : number +>a.a : any +>a : { aIndex: number; } +>a : any aIndex.aIndex; >aIndex.aIndex : number diff --git a/tests/baselines/reference/tsserver/projectReferences/find-refs-to-decl-in-other-proj-when-proj-is-loaded-and-refd-proj-loading-is-disabled-and-proj-ref-redirects-are-disabled-and-a-decl-map-is-missing.js b/tests/baselines/reference/tsserver/projectReferences/find-refs-to-decl-in-other-proj-when-proj-is-loaded-and-refd-proj-loading-is-disabled-and-proj-ref-redirects-are-disabled-and-a-decl-map-is-missing.js index e4a796ad6a22c..ce3688b728598 100644 --- a/tests/baselines/reference/tsserver/projectReferences/find-refs-to-decl-in-other-proj-when-proj-is-loaded-and-refd-proj-loading-is-disabled-and-proj-ref-redirects-are-disabled-and-a-decl-map-is-missing.js +++ b/tests/baselines/reference/tsserver/projectReferences/find-refs-to-decl-in-other-proj-when-proj-is-loaded-and-refd-proj-loading-is-disabled-and-proj-ref-redirects-are-disabled-and-a-decl-map-is-missing.js @@ -78,8 +78,6 @@ Creating configuration project /user/username/projects/myproject/b/tsconfig.json Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b/index.ts 500 undefined WatchType: Closed Script info Starting updateGraphWorker: Project: /user/username/projects/myproject/b/tsconfig.json -DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 0 undefined Project: /user/username/projects/myproject/b/tsconfig.json WatchType: Failed Lookup Locations -Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 0 undefined Project: /user/username/projects/myproject/b/tsconfig.json WatchType: Failed Lookup Locations DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b 0 undefined Project: /user/username/projects/myproject/b/tsconfig.json WatchType: Failed Lookup Locations Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b 0 undefined Project: /user/username/projects/myproject/b/tsconfig.json WatchType: Failed Lookup Locations FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 500 undefined Project: /user/username/projects/myproject/b/tsconfig.json WatchType: Missing file diff --git a/tests/baselines/reference/tsserver/projectReferences/find-refs-to-decl-in-other-proj-when-proj-is-loaded-and-refd-proj-loading-is-disabled-and-proj-ref-redirects-are-disabled-and-a-decl-map-is-present.js b/tests/baselines/reference/tsserver/projectReferences/find-refs-to-decl-in-other-proj-when-proj-is-loaded-and-refd-proj-loading-is-disabled-and-proj-ref-redirects-are-disabled-and-a-decl-map-is-present.js index de2955e6e7be2..1bc9dd129483d 100644 --- a/tests/baselines/reference/tsserver/projectReferences/find-refs-to-decl-in-other-proj-when-proj-is-loaded-and-refd-proj-loading-is-disabled-and-proj-ref-redirects-are-disabled-and-a-decl-map-is-present.js +++ b/tests/baselines/reference/tsserver/projectReferences/find-refs-to-decl-in-other-proj-when-proj-is-loaded-and-refd-proj-loading-is-disabled-and-proj-ref-redirects-are-disabled-and-a-decl-map-is-present.js @@ -78,8 +78,6 @@ Creating configuration project /user/username/projects/myproject/b/tsconfig.json Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b/index.ts 500 undefined WatchType: Closed Script info Starting updateGraphWorker: Project: /user/username/projects/myproject/b/tsconfig.json -DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 0 undefined Project: /user/username/projects/myproject/b/tsconfig.json WatchType: Failed Lookup Locations -Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 0 undefined Project: /user/username/projects/myproject/b/tsconfig.json WatchType: Failed Lookup Locations DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b 0 undefined Project: /user/username/projects/myproject/b/tsconfig.json WatchType: Failed Lookup Locations Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b 0 undefined Project: /user/username/projects/myproject/b/tsconfig.json WatchType: Failed Lookup Locations FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 500 undefined Project: /user/username/projects/myproject/b/tsconfig.json WatchType: Missing file diff --git a/tests/baselines/reference/tsserver/projectReferences/find-refs-to-decl-in-other-proj-when-proj-is-loaded-and-refd-proj-loading-is-disabled-and-proj-ref-redirects-are-enabled-and-a-decl-map-is-missing.js b/tests/baselines/reference/tsserver/projectReferences/find-refs-to-decl-in-other-proj-when-proj-is-loaded-and-refd-proj-loading-is-disabled-and-proj-ref-redirects-are-enabled-and-a-decl-map-is-missing.js index b1df27518b1b0..4711ea0e97bb8 100644 --- a/tests/baselines/reference/tsserver/projectReferences/find-refs-to-decl-in-other-proj-when-proj-is-loaded-and-refd-proj-loading-is-disabled-and-proj-ref-redirects-are-enabled-and-a-decl-map-is-missing.js +++ b/tests/baselines/reference/tsserver/projectReferences/find-refs-to-decl-in-other-proj-when-proj-is-loaded-and-refd-proj-loading-is-disabled-and-proj-ref-redirects-are-enabled-and-a-decl-map-is-missing.js @@ -77,8 +77,6 @@ For info: /user/username/projects/myproject/b/helper.ts :: Config file name: /us Creating configuration project /user/username/projects/myproject/b/tsconfig.json Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded Starting updateGraphWorker: Project: /user/username/projects/myproject/b/tsconfig.json -DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 0 undefined Project: /user/username/projects/myproject/b/tsconfig.json WatchType: Failed Lookup Locations -Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 0 undefined Project: /user/username/projects/myproject/b/tsconfig.json WatchType: Failed Lookup Locations DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b 0 undefined Project: /user/username/projects/myproject/b/tsconfig.json WatchType: Failed Lookup Locations Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b 0 undefined Project: /user/username/projects/myproject/b/tsconfig.json WatchType: Failed Lookup Locations FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 500 undefined Project: /user/username/projects/myproject/b/tsconfig.json WatchType: Missing file diff --git a/tests/baselines/reference/tsserver/projectReferences/find-refs-to-decl-in-other-proj-when-proj-is-loaded-and-refd-proj-loading-is-disabled-and-proj-ref-redirects-are-enabled-and-a-decl-map-is-present.js b/tests/baselines/reference/tsserver/projectReferences/find-refs-to-decl-in-other-proj-when-proj-is-loaded-and-refd-proj-loading-is-disabled-and-proj-ref-redirects-are-enabled-and-a-decl-map-is-present.js index b1df27518b1b0..4711ea0e97bb8 100644 --- a/tests/baselines/reference/tsserver/projectReferences/find-refs-to-decl-in-other-proj-when-proj-is-loaded-and-refd-proj-loading-is-disabled-and-proj-ref-redirects-are-enabled-and-a-decl-map-is-present.js +++ b/tests/baselines/reference/tsserver/projectReferences/find-refs-to-decl-in-other-proj-when-proj-is-loaded-and-refd-proj-loading-is-disabled-and-proj-ref-redirects-are-enabled-and-a-decl-map-is-present.js @@ -77,8 +77,6 @@ For info: /user/username/projects/myproject/b/helper.ts :: Config file name: /us Creating configuration project /user/username/projects/myproject/b/tsconfig.json Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded Starting updateGraphWorker: Project: /user/username/projects/myproject/b/tsconfig.json -DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 0 undefined Project: /user/username/projects/myproject/b/tsconfig.json WatchType: Failed Lookup Locations -Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 0 undefined Project: /user/username/projects/myproject/b/tsconfig.json WatchType: Failed Lookup Locations DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b 0 undefined Project: /user/username/projects/myproject/b/tsconfig.json WatchType: Failed Lookup Locations Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b 0 undefined Project: /user/username/projects/myproject/b/tsconfig.json WatchType: Failed Lookup Locations FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 500 undefined Project: /user/username/projects/myproject/b/tsconfig.json WatchType: Missing file diff --git a/tests/baselines/reference/tsserver/projectReferences/find-refs-to-decl-in-other-proj-when-proj-is-loaded-and-refd-proj-loading-is-enabled-and-proj-ref-redirects-are-disabled-and-a-decl-map-is-missing.js b/tests/baselines/reference/tsserver/projectReferences/find-refs-to-decl-in-other-proj-when-proj-is-loaded-and-refd-proj-loading-is-enabled-and-proj-ref-redirects-are-disabled-and-a-decl-map-is-missing.js index 67cd7b768598a..8f623cafddeb2 100644 --- a/tests/baselines/reference/tsserver/projectReferences/find-refs-to-decl-in-other-proj-when-proj-is-loaded-and-refd-proj-loading-is-enabled-and-proj-ref-redirects-are-disabled-and-a-decl-map-is-missing.js +++ b/tests/baselines/reference/tsserver/projectReferences/find-refs-to-decl-in-other-proj-when-proj-is-loaded-and-refd-proj-loading-is-enabled-and-proj-ref-redirects-are-disabled-and-a-decl-map-is-missing.js @@ -78,8 +78,6 @@ Creating configuration project /user/username/projects/myproject/b/tsconfig.json Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b/index.ts 500 undefined WatchType: Closed Script info Starting updateGraphWorker: Project: /user/username/projects/myproject/b/tsconfig.json -DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 0 undefined Project: /user/username/projects/myproject/b/tsconfig.json WatchType: Failed Lookup Locations -Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 0 undefined Project: /user/username/projects/myproject/b/tsconfig.json WatchType: Failed Lookup Locations DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b 0 undefined Project: /user/username/projects/myproject/b/tsconfig.json WatchType: Failed Lookup Locations Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b 0 undefined Project: /user/username/projects/myproject/b/tsconfig.json WatchType: Failed Lookup Locations FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 500 undefined Project: /user/username/projects/myproject/b/tsconfig.json WatchType: Missing file diff --git a/tests/baselines/reference/tsserver/projectReferences/find-refs-to-decl-in-other-proj-when-proj-is-loaded-and-refd-proj-loading-is-enabled-and-proj-ref-redirects-are-disabled-and-a-decl-map-is-present.js b/tests/baselines/reference/tsserver/projectReferences/find-refs-to-decl-in-other-proj-when-proj-is-loaded-and-refd-proj-loading-is-enabled-and-proj-ref-redirects-are-disabled-and-a-decl-map-is-present.js index e647f2e2f5c68..42e5e3e6e5109 100644 --- a/tests/baselines/reference/tsserver/projectReferences/find-refs-to-decl-in-other-proj-when-proj-is-loaded-and-refd-proj-loading-is-enabled-and-proj-ref-redirects-are-disabled-and-a-decl-map-is-present.js +++ b/tests/baselines/reference/tsserver/projectReferences/find-refs-to-decl-in-other-proj-when-proj-is-loaded-and-refd-proj-loading-is-enabled-and-proj-ref-redirects-are-disabled-and-a-decl-map-is-present.js @@ -78,8 +78,6 @@ Creating configuration project /user/username/projects/myproject/b/tsconfig.json Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b/index.ts 500 undefined WatchType: Closed Script info Starting updateGraphWorker: Project: /user/username/projects/myproject/b/tsconfig.json -DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 0 undefined Project: /user/username/projects/myproject/b/tsconfig.json WatchType: Failed Lookup Locations -Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 0 undefined Project: /user/username/projects/myproject/b/tsconfig.json WatchType: Failed Lookup Locations DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b 0 undefined Project: /user/username/projects/myproject/b/tsconfig.json WatchType: Failed Lookup Locations Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b 0 undefined Project: /user/username/projects/myproject/b/tsconfig.json WatchType: Failed Lookup Locations FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 500 undefined Project: /user/username/projects/myproject/b/tsconfig.json WatchType: Missing file diff --git a/tests/baselines/reference/tsserver/projectReferences/find-refs-to-decl-in-other-proj-when-proj-is-loaded-and-refd-proj-loading-is-enabled-and-proj-ref-redirects-are-enabled-and-a-decl-map-is-missing.js b/tests/baselines/reference/tsserver/projectReferences/find-refs-to-decl-in-other-proj-when-proj-is-loaded-and-refd-proj-loading-is-enabled-and-proj-ref-redirects-are-enabled-and-a-decl-map-is-missing.js index 74ca1adfc4a5f..dc8a96898a8c6 100644 --- a/tests/baselines/reference/tsserver/projectReferences/find-refs-to-decl-in-other-proj-when-proj-is-loaded-and-refd-proj-loading-is-enabled-and-proj-ref-redirects-are-enabled-and-a-decl-map-is-missing.js +++ b/tests/baselines/reference/tsserver/projectReferences/find-refs-to-decl-in-other-proj-when-proj-is-loaded-and-refd-proj-loading-is-enabled-and-proj-ref-redirects-are-enabled-and-a-decl-map-is-missing.js @@ -77,8 +77,6 @@ For info: /user/username/projects/myproject/b/helper.ts :: Config file name: /us Creating configuration project /user/username/projects/myproject/b/tsconfig.json Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded Starting updateGraphWorker: Project: /user/username/projects/myproject/b/tsconfig.json -DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 0 undefined Project: /user/username/projects/myproject/b/tsconfig.json WatchType: Failed Lookup Locations -Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 0 undefined Project: /user/username/projects/myproject/b/tsconfig.json WatchType: Failed Lookup Locations DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b 0 undefined Project: /user/username/projects/myproject/b/tsconfig.json WatchType: Failed Lookup Locations Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b 0 undefined Project: /user/username/projects/myproject/b/tsconfig.json WatchType: Failed Lookup Locations FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 500 undefined Project: /user/username/projects/myproject/b/tsconfig.json WatchType: Missing file diff --git a/tests/baselines/reference/tsserver/projectReferences/find-refs-to-decl-in-other-proj-when-proj-is-loaded-and-refd-proj-loading-is-enabled-and-proj-ref-redirects-are-enabled-and-a-decl-map-is-present.js b/tests/baselines/reference/tsserver/projectReferences/find-refs-to-decl-in-other-proj-when-proj-is-loaded-and-refd-proj-loading-is-enabled-and-proj-ref-redirects-are-enabled-and-a-decl-map-is-present.js index 74ca1adfc4a5f..dc8a96898a8c6 100644 --- a/tests/baselines/reference/tsserver/projectReferences/find-refs-to-decl-in-other-proj-when-proj-is-loaded-and-refd-proj-loading-is-enabled-and-proj-ref-redirects-are-enabled-and-a-decl-map-is-present.js +++ b/tests/baselines/reference/tsserver/projectReferences/find-refs-to-decl-in-other-proj-when-proj-is-loaded-and-refd-proj-loading-is-enabled-and-proj-ref-redirects-are-enabled-and-a-decl-map-is-present.js @@ -77,8 +77,6 @@ For info: /user/username/projects/myproject/b/helper.ts :: Config file name: /us Creating configuration project /user/username/projects/myproject/b/tsconfig.json Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded Starting updateGraphWorker: Project: /user/username/projects/myproject/b/tsconfig.json -DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 0 undefined Project: /user/username/projects/myproject/b/tsconfig.json WatchType: Failed Lookup Locations -Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 0 undefined Project: /user/username/projects/myproject/b/tsconfig.json WatchType: Failed Lookup Locations DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b 0 undefined Project: /user/username/projects/myproject/b/tsconfig.json WatchType: Failed Lookup Locations Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b 0 undefined Project: /user/username/projects/myproject/b/tsconfig.json WatchType: Failed Lookup Locations FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 500 undefined Project: /user/username/projects/myproject/b/tsconfig.json WatchType: Missing file diff --git a/tests/baselines/reference/tsserver/projectReferences/find-refs-to-decl-in-other-proj-when-proj-is-not-loaded-and-refd-proj-loading-is-enabled-and-proj-ref-redirects-are-disabled-and-a-decl-map-is-present.js b/tests/baselines/reference/tsserver/projectReferences/find-refs-to-decl-in-other-proj-when-proj-is-not-loaded-and-refd-proj-loading-is-enabled-and-proj-ref-redirects-are-disabled-and-a-decl-map-is-present.js index 73acf6730c022..b702f7ee33a75 100644 --- a/tests/baselines/reference/tsserver/projectReferences/find-refs-to-decl-in-other-proj-when-proj-is-not-loaded-and-refd-proj-loading-is-enabled-and-proj-ref-redirects-are-disabled-and-a-decl-map-is-present.js +++ b/tests/baselines/reference/tsserver/projectReferences/find-refs-to-decl-in-other-proj-when-proj-is-not-loaded-and-refd-proj-loading-is-enabled-and-proj-ref-redirects-are-disabled-and-a-decl-map-is-present.js @@ -81,8 +81,6 @@ Creating configuration project /user/username/projects/myproject/b/tsconfig.json Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b/helper.ts 500 undefined WatchType: Closed Script info Starting updateGraphWorker: Project: /user/username/projects/myproject/b/tsconfig.json -DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 0 undefined Project: /user/username/projects/myproject/b/tsconfig.json WatchType: Failed Lookup Locations -Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 0 undefined Project: /user/username/projects/myproject/b/tsconfig.json WatchType: Failed Lookup Locations DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b 0 undefined Project: /user/username/projects/myproject/b/tsconfig.json WatchType: Failed Lookup Locations Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b 0 undefined Project: /user/username/projects/myproject/b/tsconfig.json WatchType: Failed Lookup Locations FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 500 undefined Project: /user/username/projects/myproject/b/tsconfig.json WatchType: Missing file diff --git a/tests/baselines/reference/tsserver/projectReferences/find-refs-to-decl-in-other-proj-when-proj-is-not-loaded-and-refd-proj-loading-is-enabled-and-proj-ref-redirects-are-enabled-and-a-decl-map-is-missing.js b/tests/baselines/reference/tsserver/projectReferences/find-refs-to-decl-in-other-proj-when-proj-is-not-loaded-and-refd-proj-loading-is-enabled-and-proj-ref-redirects-are-enabled-and-a-decl-map-is-missing.js index 296aa5a020cfc..55d79cb9042d0 100644 --- a/tests/baselines/reference/tsserver/projectReferences/find-refs-to-decl-in-other-proj-when-proj-is-not-loaded-and-refd-proj-loading-is-enabled-and-proj-ref-redirects-are-enabled-and-a-decl-map-is-missing.js +++ b/tests/baselines/reference/tsserver/projectReferences/find-refs-to-decl-in-other-proj-when-proj-is-not-loaded-and-refd-proj-loading-is-enabled-and-proj-ref-redirects-are-enabled-and-a-decl-map-is-missing.js @@ -79,8 +79,6 @@ Creating configuration project /user/username/projects/myproject/b/tsconfig.json Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b/helper.ts 500 undefined WatchType: Closed Script info Starting updateGraphWorker: Project: /user/username/projects/myproject/b/tsconfig.json -DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 0 undefined Project: /user/username/projects/myproject/b/tsconfig.json WatchType: Failed Lookup Locations -Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 0 undefined Project: /user/username/projects/myproject/b/tsconfig.json WatchType: Failed Lookup Locations DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b 0 undefined Project: /user/username/projects/myproject/b/tsconfig.json WatchType: Failed Lookup Locations Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b 0 undefined Project: /user/username/projects/myproject/b/tsconfig.json WatchType: Failed Lookup Locations FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 500 undefined Project: /user/username/projects/myproject/b/tsconfig.json WatchType: Missing file diff --git a/tests/baselines/reference/tsserver/projectReferences/find-refs-to-decl-in-other-proj-when-proj-is-not-loaded-and-refd-proj-loading-is-enabled-and-proj-ref-redirects-are-enabled-and-a-decl-map-is-present.js b/tests/baselines/reference/tsserver/projectReferences/find-refs-to-decl-in-other-proj-when-proj-is-not-loaded-and-refd-proj-loading-is-enabled-and-proj-ref-redirects-are-enabled-and-a-decl-map-is-present.js index 296aa5a020cfc..55d79cb9042d0 100644 --- a/tests/baselines/reference/tsserver/projectReferences/find-refs-to-decl-in-other-proj-when-proj-is-not-loaded-and-refd-proj-loading-is-enabled-and-proj-ref-redirects-are-enabled-and-a-decl-map-is-present.js +++ b/tests/baselines/reference/tsserver/projectReferences/find-refs-to-decl-in-other-proj-when-proj-is-not-loaded-and-refd-proj-loading-is-enabled-and-proj-ref-redirects-are-enabled-and-a-decl-map-is-present.js @@ -79,8 +79,6 @@ Creating configuration project /user/username/projects/myproject/b/tsconfig.json Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b/helper.ts 500 undefined WatchType: Closed Script info Starting updateGraphWorker: Project: /user/username/projects/myproject/b/tsconfig.json -DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 0 undefined Project: /user/username/projects/myproject/b/tsconfig.json WatchType: Failed Lookup Locations -Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 0 undefined Project: /user/username/projects/myproject/b/tsconfig.json WatchType: Failed Lookup Locations DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b 0 undefined Project: /user/username/projects/myproject/b/tsconfig.json WatchType: Failed Lookup Locations Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b 0 undefined Project: /user/username/projects/myproject/b/tsconfig.json WatchType: Failed Lookup Locations FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 500 undefined Project: /user/username/projects/myproject/b/tsconfig.json WatchType: Missing file diff --git a/tests/cases/conformance/moduleResolution/importFromDot.ts b/tests/cases/conformance/moduleResolution/importFromDot.ts new file mode 100644 index 0000000000000..eb28f6943f6ca --- /dev/null +++ b/tests/cases/conformance/moduleResolution/importFromDot.ts @@ -0,0 +1,10 @@ +// @module: commonjs + +// @Filename: a.ts +export const rootA = 0; + +// @Filename: a/index.ts +export const indexInA = 0; + +// @Filename: a/b.ts +import { indexInA, rootA } from ".";