Skip to content

Explicitly avoid canonicalizing paths during configuration handling #18316

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ namespace ts {
let symbolInstantiationDepth = 0;

const emptySymbols = createSymbolTable();
const identityMapper: (type: Type) => Type = identity;

const compilerOptions = host.getCompilerOptions();
const languageVersion = getEmitScriptTarget(compilerOptions);
Expand Down Expand Up @@ -8113,10 +8114,6 @@ namespace ts {
mapper;
}

function identityMapper(type: Type): Type {
return type;
}

function combineTypeMappers(mapper1: TypeMapper, mapper2: TypeMapper): TypeMapper {
return t => instantiateType(mapper1(t), mapper2);
}
Expand Down
12 changes: 9 additions & 3 deletions src/compiler/commandLineParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1385,6 +1385,12 @@ namespace ts {
return x === undefined || x === null;
}

function directoryOfCombinedPath(fileName: string, basePath: string) {
// Use the `identity` function to avoid canonicalizing the path, as it must remain noncanonical
// until consistient casing errors are reported
return getDirectoryPath(toPath(fileName, basePath, identity));
}

/**
* Parse the contents of a config file from json or json source file (tsconfig.json).
* @param json The contents of the config file to parse
Expand Down Expand Up @@ -1467,7 +1473,7 @@ namespace ts {
includeSpecs = ["**/*"];
}

const result = matchFileNames(fileNames, includeSpecs, excludeSpecs, configFileName ? getDirectoryPath(toPath(configFileName, basePath, createGetCanonicalFileName(host.useCaseSensitiveFileNames))) : basePath, options, host, errors, extraFileExtensions, sourceFile);
const result = matchFileNames(fileNames, includeSpecs, excludeSpecs, configFileName ? directoryOfCombinedPath(configFileName, basePath) : basePath, options, host, errors, extraFileExtensions, sourceFile);

if (result.fileNames.length === 0 && !hasProperty(raw, "files") && resolutionStack.length === 0) {
errors.push(
Expand Down Expand Up @@ -1577,7 +1583,7 @@ namespace ts {
errors.push(createCompilerDiagnostic(Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "extends", "string"));
}
else {
const newBase = configFileName ? getDirectoryPath(toPath(configFileName, basePath, getCanonicalFileName)) : basePath;
const newBase = configFileName ? directoryOfCombinedPath(configFileName, basePath) : basePath;
extendedConfigPath = getExtendsConfigPath(json.extends, host, newBase, getCanonicalFileName, errors, createCompilerDiagnostic);
}
}
Expand Down Expand Up @@ -1610,7 +1616,7 @@ namespace ts {
onSetValidOptionKeyValueInRoot(key: string, _keyNode: PropertyName, value: CompilerOptionsValue, valueNode: Expression) {
switch (key) {
case "extends":
const newBase = configFileName ? getDirectoryPath(toPath(configFileName, basePath, getCanonicalFileName)) : basePath;
const newBase = configFileName ? directoryOfCombinedPath(configFileName, basePath) : basePath;
extendedConfigPath = getExtendsConfigPath(
<string>value,
host,
Expand Down
3 changes: 3 additions & 0 deletions src/compiler/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1228,6 +1228,9 @@ namespace ts {
/** Does nothing. */
export function noop(): void {}

/** Returns its argument. */
export function identity<T>(x: T) { return x; }

/** Throws an error because a function is not implemented. */
export function notImplemented(): never {
throw new Error("Not implemented");
Expand Down