mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge pull request #21205 from uniqueiniquity/resolveTripleSlashReferencePaths
Fix Windows-style absolute paths in triple-slash directives
This commit is contained in:
@@ -1909,7 +1909,7 @@ namespace ts {
|
||||
return p2 + 1;
|
||||
}
|
||||
if (path.charCodeAt(1) === CharacterCodes.colon) {
|
||||
if (path.charCodeAt(2) === CharacterCodes.slash) return 3;
|
||||
if (path.charCodeAt(2) === CharacterCodes.slash || path.charCodeAt(2) === CharacterCodes.backslash) return 3;
|
||||
}
|
||||
// Per RFC 1738 'file' URI schema has the shape file://<host>/<path>
|
||||
// if <host> is omitted then it is assumed that host value is 'localhost',
|
||||
|
||||
@@ -2821,6 +2821,31 @@ namespace ts.projectSystem {
|
||||
checkWatchedDirectories(host, watchedRecursiveDirectories, /*recursive*/ true);
|
||||
});
|
||||
|
||||
it("Properly handle Windows-style outDir", () => {
|
||||
const configFile: FileOrFolder = {
|
||||
path: "C:\\a\\tsconfig.json",
|
||||
content: JSON.stringify({
|
||||
compilerOptions: {
|
||||
outDir: `C:\\a\\b`
|
||||
},
|
||||
include: ["*.ts"]
|
||||
})
|
||||
};
|
||||
const file1: FileOrFolder = {
|
||||
path: "C:\\a\\f1.ts",
|
||||
content: "let x = 1;"
|
||||
};
|
||||
|
||||
const host = createServerHost([file1, configFile], { useWindowsStylePaths: true });
|
||||
const projectService = createProjectService(host);
|
||||
|
||||
projectService.openClientFile(file1.path);
|
||||
checkNumberOfProjects(projectService, { configuredProjects: 1 });
|
||||
const project = configuredProjectAt(projectService, 0);
|
||||
checkProjectActualFiles(project, [normalizePath(file1.path), normalizePath(configFile.path)]);
|
||||
const options = project.getCompilerOptions();
|
||||
assert.equal(options.outDir, "C:/a/b", "");
|
||||
});
|
||||
});
|
||||
|
||||
describe("tsserverProjectSystem Proper errors", () => {
|
||||
|
||||
Reference in New Issue
Block a user