Merge branch 'master' into typesVersions

This commit is contained in:
Ron Buckton
2018-08-29 13:26:13 -07:00
39 changed files with 11363 additions and 10420 deletions
+2 -2
View File
@@ -5,8 +5,8 @@ namespace ts {
const projFs = loadProjectFromDisk("tests/projects/sample1");
const allExpectedOutputs = ["/src/tests/index.js",
"/src/core/index.js", "/src/core/index.d.ts",
"/src/logic/index.js", "/src/logic/index.d.ts"];
"/src/core/index.js", "/src/core/index.d.ts", "/src/core/index.d.ts.map",
"/src/logic/index.js", "/src/logic/index.js.map", "/src/logic/index.d.ts"];
describe("tsbuild - sanity check of clean build of 'sample1' project", () => {
it("can build the sample project 'sample1' without error", () => {
@@ -2863,7 +2863,7 @@ namespace ts.projectSystem {
const session = createSession(host, {
canUseEvents: true,
eventHandler: e => {
if (e.eventName === server.ConfigFileDiagEvent || e.eventName === server.ProjectsUpdatedInBackgroundEvent || e.eventName === server.ProjectInfoTelemetryEvent || e.eventName === server.OpenFileInfoTelemetryEvent || e.eventName === server.LargeFileReferencedEvent) {
if (e.eventName === server.ConfigFileDiagEvent || e.eventName === server.ProjectsUpdatedInBackgroundEvent || e.eventName === server.ProjectInfoTelemetryEvent || e.eventName === server.OpenFileInfoTelemetryEvent || e.eventName === server.LargeFileReferencedEvent || e.eventName === server.SurveyReady) {
return;
}
assert.equal(e.eventName, server.ProjectLanguageServiceStateEvent);
@@ -3539,6 +3539,121 @@ namespace ts.projectSystem {
}
});
function createSessionWithEventHandler(host: TestServerHost) {
const surveyEvents: server.SurveyReady[] = [];
const session = createSession(host, {
eventHandler: e => {
if (e.eventName === server.SurveyReady) {
surveyEvents.push(e);
}
}
});
return { session, verifySurveyReadyEvent };
function verifySurveyReadyEvent(numberOfEvents: number) {
assert.equal(surveyEvents.length, numberOfEvents);
const expectedEvents = numberOfEvents === 0 ? [] : [{
eventName: server.SurveyReady,
data: { surveyId: "checkJs" }
}];
assert.deepEqual(surveyEvents, expectedEvents);
}
}
it("doesn't log an event when checkJs isn't set", () => {
const projectRoot = "/user/username/projects/project";
const file: File = {
path: `${projectRoot}/src/file.ts`,
content: "export var y = 10;"
};
const tsconfig: File = {
path: `${projectRoot}/tsconfig.json`,
content: JSON.stringify({ compilerOptions: { } }),
};
const host = createServerHost([file, tsconfig]);
const { session, verifySurveyReadyEvent } = createSessionWithEventHandler(host);
const service = session.getProjectService();
openFilesForSession([file], session);
checkNumberOfProjects(service, { configuredProjects: 1 });
const project = service.configuredProjects.get(tsconfig.path)!;
checkProjectActualFiles(project, [file.path, tsconfig.path]);
verifySurveyReadyEvent(0);
});
it("logs an event when checkJs is set", () => {
const projectRoot = "/user/username/projects/project";
const file: File = {
path: `${projectRoot}/src/file.ts`,
content: "export var y = 10;"
};
const tsconfig: File = {
path: `${projectRoot}/tsconfig.json`,
content: JSON.stringify({ compilerOptions: { checkJs: true } }),
};
const host = createServerHost([file, tsconfig]);
const { session, verifySurveyReadyEvent } = createSessionWithEventHandler(host);
openFilesForSession([file], session);
verifySurveyReadyEvent(1);
});
it("logs an event when checkJs is set, only the first time", () => {
const projectRoot = "/user/username/projects/project";
const file: File = {
path: `${projectRoot}/src/file.ts`,
content: "export var y = 10;"
};
const rando: File = {
path: `/rando/calrissian.ts`,
content: "export function f() { }"
};
const tsconfig: File = {
path: `${projectRoot}/tsconfig.json`,
content: JSON.stringify({ compilerOptions: { checkJs: true } }),
};
const host = createServerHost([file, tsconfig]);
const { session, verifySurveyReadyEvent } = createSessionWithEventHandler(host);
openFilesForSession([file], session);
verifySurveyReadyEvent(1);
closeFilesForSession([file], session);
openFilesForSession([rando], session);
openFilesForSession([file], session);
verifySurveyReadyEvent(1);
});
it("logs an event when checkJs is set after closing and reopening", () => {
const projectRoot = "/user/username/projects/project";
const file: File = {
path: `${projectRoot}/src/file.ts`,
content: "export var y = 10;"
};
const rando: File = {
path: `/rando/calrissian.ts`,
content: "export function f() { }"
};
const tsconfig: File = {
path: `${projectRoot}/tsconfig.json`,
content: JSON.stringify({ }),
};
const host = createServerHost([file, tsconfig]);
const { session, verifySurveyReadyEvent } = createSessionWithEventHandler(host);
openFilesForSession([file], session);
verifySurveyReadyEvent(0);
closeFilesForSession([file], session);
openFilesForSession([rando], session);
host.writeFile(tsconfig.path, JSON.stringify({ compilerOptions: { checkJs: true } }));
openFilesForSession([file], session);
verifySurveyReadyEvent(1);
});
describe("CompileOnSaveAffectedFileListRequest with and without projectFileName in request", () => {
const projectRoot = "/user/username/projects/myproject";
const core: File = {