mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-19 00:42:28 -05:00
Component commits:0cb4514766Add test to show how scope messes with casinga3ea961838Do not canonicalize the file names when getting absolute paths Fixes #50544dfb1e401f0Unnecessary exportsfc35e0a032Add test for self referencing package9076f4d57dFix self reference package with casing Co-authored-by: Sheetal Nandi <shkamat@microsoft.com>
This commit is contained in:
@@ -2227,7 +2227,7 @@ namespace ts {
|
||||
function toAbsolutePath(path: string | undefined): string | undefined;
|
||||
function toAbsolutePath(path: string | undefined): string | undefined {
|
||||
if (path === undefined) return path;
|
||||
return hostGetCanonicalFileName({ useCaseSensitiveFileNames })(getNormalizedAbsolutePath(path, state.host.getCurrentDirectory?.()));
|
||||
return getNormalizedAbsolutePath(path, state.host.getCurrentDirectory?.());
|
||||
}
|
||||
|
||||
function combineDirectoryPath(root: string, dir: string) {
|
||||
@@ -2249,7 +2249,7 @@ namespace ts {
|
||||
if ((extensions === Extensions.TypeScript || extensions === Extensions.JavaScript || extensions === Extensions.Json)
|
||||
&& (state.compilerOptions.declarationDir || state.compilerOptions.outDir)
|
||||
&& finalPath.indexOf("/node_modules/") === -1
|
||||
&& (state.compilerOptions.configFile ? startsWith(toAbsolutePath(state.compilerOptions.configFile.fileName), scope.packageDirectory) : true)
|
||||
&& (state.compilerOptions.configFile ? containsPath(scope.packageDirectory, toAbsolutePath(state.compilerOptions.configFile.fileName), !useCaseSensitiveFileNames()) : true)
|
||||
) {
|
||||
// So that all means we'll only try these guesses for files outside `node_modules` in a directory where the `package.json` and `tsconfig.json` are siblings.
|
||||
// Even with all that, we still don't know if the root of the output file structure will be (relative to the package file)
|
||||
@@ -2310,7 +2310,7 @@ namespace ts {
|
||||
for (const commonSourceDirGuess of commonSourceDirGuesses) {
|
||||
const candidateDirectories = getOutputDirectoriesForBaseDirectory(commonSourceDirGuess);
|
||||
for (const candidateDir of candidateDirectories) {
|
||||
if (startsWith(finalPath, candidateDir)) {
|
||||
if (containsPath(candidateDir, finalPath, !useCaseSensitiveFileNames())) {
|
||||
// The matched export is looking up something in either the out declaration or js dir, now map the written path back into the source dir and source extension
|
||||
const pathFragment = finalPath.slice(candidateDir.length + 1); // +1 to also remove directory seperator
|
||||
const possibleInputBase = combinePaths(commonSourceDirGuess, pathFragment);
|
||||
|
||||
@@ -262,5 +262,69 @@ a;b;
|
||||
verifyDirSymlink("when import matches disk but directory symlink target does not", `${projectRoot}/XY`, `${projectRoot}/XY`, `./Xy`);
|
||||
verifyDirSymlink("when import and directory symlink target agree but do not match disk", `${projectRoot}/XY`, `${projectRoot}/Xy`, `./Xy`);
|
||||
verifyDirSymlink("when import, directory symlink target, and disk are all different", `${projectRoot}/XY`, `${projectRoot}/Xy`, `./yX`);
|
||||
|
||||
verifyTscWatch({
|
||||
scenario: "forceConsistentCasingInFileNames",
|
||||
subScenario: "with nodeNext resolution",
|
||||
commandLineArgs: ["--w", "--explainFiles"],
|
||||
sys: () => createWatchedSystem({
|
||||
"/Users/name/projects/web/src/bin.ts": `import { foo } from "yargs";`,
|
||||
"/Users/name/projects/web/node_modules/@types/yargs/index.d.ts": "export function foo(): void;",
|
||||
"/Users/name/projects/web/node_modules/@types/yargs/index.d.mts": "export function foo(): void;",
|
||||
"/Users/name/projects/web/node_modules/@types/yargs/package.json": JSON.stringify({
|
||||
name: "yargs",
|
||||
version: "17.0.12",
|
||||
exports: {
|
||||
".": {
|
||||
types: {
|
||||
import: "./index.d.mts",
|
||||
default: "./index.d.ts"
|
||||
}
|
||||
},
|
||||
}
|
||||
}),
|
||||
"/Users/name/projects/web/tsconfig.json": JSON.stringify({
|
||||
compilerOptions: {
|
||||
moduleResolution: "nodenext",
|
||||
forceConsistentCasingInFileNames: true,
|
||||
traceResolution: true,
|
||||
}
|
||||
}),
|
||||
[libFile.path]: libFile.content,
|
||||
}, { currentDirectory: "/Users/name/projects/web" }),
|
||||
changes: emptyArray,
|
||||
});
|
||||
|
||||
verifyTscWatch({
|
||||
scenario: "forceConsistentCasingInFileNames",
|
||||
subScenario: "self name package reference",
|
||||
commandLineArgs: ["-w", "--explainFiles"],
|
||||
sys: () => createWatchedSystem({
|
||||
"/Users/name/projects/web/package.json": JSON.stringify({
|
||||
name: "@this/package",
|
||||
type: "module",
|
||||
exports: {
|
||||
".": "./dist/index.js"
|
||||
}
|
||||
}),
|
||||
"/Users/name/projects/web/index.ts": Utils.dedent`
|
||||
import * as me from "@this/package";
|
||||
me.thing();
|
||||
export function thing(): void {}
|
||||
`,
|
||||
"/Users/name/projects/web/tsconfig.json": JSON.stringify({
|
||||
compilerOptions: {
|
||||
module: "nodenext",
|
||||
outDir: "./dist",
|
||||
declarationDir: "./types",
|
||||
composite: true,
|
||||
forceConsistentCasingInFileNames: true,
|
||||
traceResolution: true,
|
||||
}
|
||||
}),
|
||||
"/a/lib/lib.esnext.full.d.ts": libFile.content,
|
||||
}, { currentDirectory: "/Users/name/projects/web" }),
|
||||
changes: emptyArray,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user