mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge branch 'master' of https://github.com/Microsoft/TypeScript into feature/eslint
This commit is contained in:
@@ -185,7 +185,8 @@ function stripRushStageNumbers(result: string): string {
|
||||
* so we purge as much of the gulp output as we can
|
||||
*/
|
||||
function sanitizeUnimportantGulpOutput(result: string): string {
|
||||
return result.replace(/^.*(\] (Starting)|(Finished)).*$/gm, "") // task start/end messages (nondeterministic order)
|
||||
return result.replace(/^.*(\] (Starting)|(Finished)).*$/gm, "") // "gulp" task start/end messages (nondeterministic order)
|
||||
.replace(/^.*(\] . (finished)|(started)).*$/gm, "") // "just" task start/end messages (nondeterministic order)
|
||||
.replace(/^.*\] Respawned to PID: \d+.*$/gm, "") // PID of child is OS and system-load dependent (likely stableish in a container but still dangerous)
|
||||
.replace(/\n+/g, "\n");
|
||||
}
|
||||
@@ -193,14 +194,17 @@ function sanitizeUnimportantGulpOutput(result: string): string {
|
||||
function sanitizeTimestamps(result: string): string {
|
||||
return result.replace(/\[\d?\d:\d\d:\d\d (A|P)M\]/g, "[XX:XX:XX XM]")
|
||||
.replace(/\[\d?\d:\d\d:\d\d\]/g, "[XX:XX:XX]")
|
||||
.replace(/\/\d+-\d+-[\d_TZ]+-debug.log/g, "\/XXXX-XX-XXXXXXXXX-debug.log")
|
||||
.replace(/\d+(\.\d+)? sec(onds?)?/g, "? seconds")
|
||||
.replace(/\d+(\.\d+)? min(utes?)?/g, "")
|
||||
.replace(/\d+(\.\d+)?( m)?s/g, "?s");
|
||||
.replace(/\d+(\.\d+)? ?m?s/g, "?s")
|
||||
.replace(/ \(\?s\)/g, "");
|
||||
}
|
||||
|
||||
function sanitizeVersionSpecifiers(result: string): string {
|
||||
return result
|
||||
.replace(/\d+.\d+.\d+-insiders.\d\d\d\d\d\d\d\d/g, "X.X.X-insiders.xxxxxxxx")
|
||||
.replace(/Rush Multi-Project Build Tool (\d+)\.\d+\.\d+/g, "Rush Multi-Project Build Tool $1.X.X")
|
||||
.replace(/([@v\()])\d+\.\d+\.\d+/g, "$1X.X.X");
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,18 @@ namespace ts {
|
||||
verifyNewLines(content, { newLine: NewLineKind.LineFeed });
|
||||
}
|
||||
|
||||
function verifyOutliningSpanNewLines(content: string, options: CompilerOptions) {
|
||||
const ls = testLSWithFiles(options, [{
|
||||
content,
|
||||
fileOptions: {},
|
||||
unitName: "input.ts"
|
||||
}]);
|
||||
const span = ls.getOutliningSpans("input.ts")[0];
|
||||
const textAfterSpanCollapse = content.substring(span.textSpan.start + span.textSpan.length);
|
||||
assert(textAfterSpanCollapse.match(options.newLine === NewLineKind.CarriageReturnLineFeed ? /\r\n/ : /[^\r]\n/), "expected to find appropriate newlines");
|
||||
assert(!textAfterSpanCollapse.match(options.newLine === NewLineKind.CarriageReturnLineFeed ? /[^\r]\n/ : /\r\n/), "expected not to find inappropriate newlines");
|
||||
}
|
||||
|
||||
it("should exist and respect provided compiler options", () => {
|
||||
verifyBothNewLines(`
|
||||
function foo() {
|
||||
@@ -45,5 +57,15 @@ namespace ts {
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
it("should respect CRLF line endings around outlining spans", () => {
|
||||
verifyOutliningSpanNewLines("// comment not included\r\n// #region name\r\nlet x: string = \"x\";\r\n// #endregion name\r\n",
|
||||
{ newLine: NewLineKind.CarriageReturnLineFeed });
|
||||
});
|
||||
|
||||
it("should respect LF line endings around outlining spans", () => {
|
||||
verifyOutliningSpanNewLines("// comment not included\n// #region name\nlet x: string = \"x\";\n// #endregion name\n\n",
|
||||
{ newLine: NewLineKind.LineFeed });
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -866,12 +866,12 @@ namespace ts.projectSystem {
|
||||
const projectService = createProjectService(host);
|
||||
projectService.openClientFile(file1.path);
|
||||
host.runQueuedTimeoutCallbacks();
|
||||
// Since there is no file open from configFile it would be closed
|
||||
checkNumberOfConfiguredProjects(projectService, 0);
|
||||
checkNumberOfInferredProjects(projectService, 1);
|
||||
|
||||
// Since file1 refers to config file as the default project, it needs to be kept alive
|
||||
checkNumberOfProjects(projectService, { inferredProjects: 1, configuredProjects: 1 });
|
||||
const inferredProject = projectService.inferredProjects[0];
|
||||
assert.isTrue(inferredProject.containsFile(<server.NormalizedPath>file1.path));
|
||||
assert.isFalse(projectService.configuredProjects.get(configFile.path)!.containsFile(<server.NormalizedPath>file1.path));
|
||||
});
|
||||
|
||||
it("should be able to handle @types if input file list is empty", () => {
|
||||
@@ -898,8 +898,8 @@ namespace ts.projectSystem {
|
||||
const projectService = createProjectService(host);
|
||||
|
||||
projectService.openClientFile(f.path);
|
||||
// Since no file from the configured project is open, it would be closed immediately
|
||||
projectService.checkNumberOfProjects({ configuredProjects: 0, inferredProjects: 1 });
|
||||
// Since f refers to config file as the default project, it needs to be kept alive
|
||||
projectService.checkNumberOfProjects({ configuredProjects: 1, inferredProjects: 1 });
|
||||
});
|
||||
|
||||
it("should tolerate invalid include files that start in subDirectory", () => {
|
||||
@@ -924,8 +924,8 @@ namespace ts.projectSystem {
|
||||
const projectService = createProjectService(host);
|
||||
|
||||
projectService.openClientFile(f.path);
|
||||
// Since no file from the configured project is open, it would be closed immediately
|
||||
projectService.checkNumberOfProjects({ configuredProjects: 0, inferredProjects: 1 });
|
||||
// Since f refers to config file as the default project, it needs to be kept alive
|
||||
projectService.checkNumberOfProjects({ configuredProjects: 1, inferredProjects: 1 });
|
||||
});
|
||||
|
||||
it("Changed module resolution reflected when specifying files list", () => {
|
||||
|
||||
@@ -345,5 +345,92 @@ namespace ts.projectSystem {
|
||||
it("inferred projects per project root with case insensitive system", () => {
|
||||
verifyProjectRootWithCaseSensitivity(/*useCaseSensitiveFileNames*/ false);
|
||||
});
|
||||
|
||||
it("should still retain configured project created while opening the file", () => {
|
||||
const projectRoot = "/user/username/projects/project";
|
||||
const appFile: File = {
|
||||
path: `${projectRoot}/app.ts`,
|
||||
content: `const app = 20;`
|
||||
};
|
||||
const config: File = {
|
||||
path: `${projectRoot}/tsconfig.json`,
|
||||
content: "{}"
|
||||
};
|
||||
const jsFile1: File = {
|
||||
path: `${projectRoot}/jsFile1.js`,
|
||||
content: `const jsFile1 = 10;`
|
||||
};
|
||||
const jsFile2: File = {
|
||||
path: `${projectRoot}/jsFile2.js`,
|
||||
content: `const jsFile2 = 10;`
|
||||
};
|
||||
const host = createServerHost([appFile, libFile, config, jsFile1, jsFile2]);
|
||||
const projectService = createProjectService(host);
|
||||
const originalSet = projectService.configuredProjects.set;
|
||||
const originalDelete = projectService.configuredProjects.delete;
|
||||
const configuredCreated = createMap<true>();
|
||||
const configuredRemoved = createMap<true>();
|
||||
projectService.configuredProjects.set = (key, value) => {
|
||||
assert.isFalse(configuredCreated.has(key));
|
||||
configuredCreated.set(key, true);
|
||||
return originalSet.call(projectService.configuredProjects, key, value);
|
||||
};
|
||||
projectService.configuredProjects.delete = key => {
|
||||
assert.isFalse(configuredRemoved.has(key));
|
||||
configuredRemoved.set(key, true);
|
||||
return originalDelete.call(projectService.configuredProjects, key);
|
||||
};
|
||||
|
||||
// Do not remove config project when opening jsFile that is not present as part of config project
|
||||
projectService.openClientFile(jsFile1.path);
|
||||
checkNumberOfProjects(projectService, { inferredProjects: 1, configuredProjects: 1 });
|
||||
checkProjectActualFiles(projectService.inferredProjects[0], [jsFile1.path, libFile.path]);
|
||||
const project = projectService.configuredProjects.get(config.path)!;
|
||||
checkProjectActualFiles(project, [appFile.path, config.path, libFile.path]);
|
||||
checkConfiguredProjectCreatedAndNotDeleted();
|
||||
|
||||
// Do not remove config project when opening jsFile that is not present as part of config project
|
||||
projectService.closeClientFile(jsFile1.path);
|
||||
checkNumberOfProjects(projectService, { inferredProjects: 1, configuredProjects: 1 });
|
||||
projectService.openClientFile(jsFile2.path);
|
||||
checkNumberOfProjects(projectService, { inferredProjects: 1, configuredProjects: 1 });
|
||||
checkProjectActualFiles(projectService.inferredProjects[0], [jsFile2.path, libFile.path]);
|
||||
checkProjectActualFiles(project, [appFile.path, config.path, libFile.path]);
|
||||
checkConfiguredProjectNotCreatedAndNotDeleted();
|
||||
|
||||
// Do not remove config project when opening jsFile that is not present as part of config project
|
||||
projectService.openClientFile(jsFile1.path);
|
||||
checkNumberOfProjects(projectService, { inferredProjects: 2, configuredProjects: 1 });
|
||||
checkProjectActualFiles(projectService.inferredProjects[0], [jsFile2.path, libFile.path]);
|
||||
checkProjectActualFiles(projectService.inferredProjects[1], [jsFile1.path, libFile.path]);
|
||||
checkProjectActualFiles(project, [appFile.path, config.path, libFile.path]);
|
||||
checkConfiguredProjectNotCreatedAndNotDeleted();
|
||||
|
||||
// When opening file that doesnt fall back to the config file, we remove the config project
|
||||
projectService.openClientFile(libFile.path);
|
||||
checkNumberOfProjects(projectService, { inferredProjects: 2 });
|
||||
checkProjectActualFiles(projectService.inferredProjects[0], [jsFile2.path, libFile.path]);
|
||||
checkProjectActualFiles(projectService.inferredProjects[1], [jsFile1.path, libFile.path]);
|
||||
checkConfiguredProjectNotCreatedButDeleted();
|
||||
|
||||
function checkConfiguredProjectCreatedAndNotDeleted() {
|
||||
assert.equal(configuredCreated.size, 1);
|
||||
assert.isTrue(configuredCreated.has(config.path));
|
||||
assert.equal(configuredRemoved.size, 0);
|
||||
configuredCreated.clear();
|
||||
}
|
||||
|
||||
function checkConfiguredProjectNotCreatedAndNotDeleted() {
|
||||
assert.equal(configuredCreated.size, 0);
|
||||
assert.equal(configuredRemoved.size, 0);
|
||||
}
|
||||
|
||||
function checkConfiguredProjectNotCreatedButDeleted() {
|
||||
assert.equal(configuredCreated.size, 0);
|
||||
assert.equal(configuredRemoved.size, 1);
|
||||
assert.isTrue(configuredRemoved.has(config.path));
|
||||
configuredRemoved.clear();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -637,13 +637,17 @@ namespace ts.projectSystem {
|
||||
path: "/a/main.js",
|
||||
content: "var y = 1"
|
||||
};
|
||||
const f3 = {
|
||||
path: "/main.js",
|
||||
content: "var y = 1"
|
||||
};
|
||||
const config = {
|
||||
path: "/a/tsconfig.json",
|
||||
content: JSON.stringify({
|
||||
compilerOptions: { allowJs: true }
|
||||
})
|
||||
};
|
||||
const host = createServerHost([f1, f2, config]);
|
||||
const host = createServerHost([f1, f2, f3, config]);
|
||||
const projectService = createProjectService(host);
|
||||
projectService.setHostConfiguration({
|
||||
extraFileExtensions: [
|
||||
@@ -655,13 +659,19 @@ namespace ts.projectSystem {
|
||||
projectService.checkNumberOfProjects({ configuredProjects: 1 });
|
||||
checkProjectActualFiles(configuredProjectAt(projectService, 0), [f1.path, config.path]);
|
||||
|
||||
// Should close configured project with next file open
|
||||
// Since f2 refers to config file as the default project, it needs to be kept alive
|
||||
projectService.closeClientFile(f1.path);
|
||||
|
||||
projectService.openClientFile(f2.path);
|
||||
projectService.checkNumberOfProjects({ inferredProjects: 1, configuredProjects: 1 });
|
||||
assert.isDefined(projectService.configuredProjects.get(config.path));
|
||||
checkProjectActualFiles(projectService.inferredProjects[0], [f2.path]);
|
||||
|
||||
// Should close configured project with next file open
|
||||
projectService.closeClientFile(f2.path);
|
||||
projectService.openClientFile(f3.path);
|
||||
projectService.checkNumberOfProjects({ inferredProjects: 1 });
|
||||
assert.isUndefined(projectService.configuredProjects.get(config.path));
|
||||
checkProjectActualFiles(projectService.inferredProjects[0], [f2.path]);
|
||||
checkProjectActualFiles(projectService.inferredProjects[0], [f3.path]);
|
||||
});
|
||||
|
||||
it("tsconfig script block support", () => {
|
||||
|
||||
Reference in New Issue
Block a user