diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index 5ea72a6bbf2..7d6d0f67d7a 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 d09108d34c7..ebc837feb33 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 00000000000..567c61451d9 --- /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 00000000000..0bccb84eeb2 --- /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 00000000000..2431f381a34 --- /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 00000000000..f595b92a996 --- /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 00000000000..60125b35a58 --- /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 c6c49464380..ddaf5befb06 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 fb77f852988..b60d3bc6aab 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'. ========", - "======== 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/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 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 beec18ea4aa..41c2a160afa 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 e4a796ad6a2..ce3688b7285 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 de2955e6e7b..1bc9dd12948 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 b1df27518b1..4711ea0e97b 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 b1df27518b1..4711ea0e97b 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 67cd7b76859..8f623cafdde 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 e647f2e2f5c..42e5e3e6e51 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 74ca1adfc4a..dc8a96898a8 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 74ca1adfc4a..dc8a96898a8 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 73acf6730c0..b702f7ee33a 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 296aa5a020c..55d79cb9042 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 296aa5a020c..55d79cb9042 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 00000000000..eb28f6943f6 --- /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 ".";