Skip to content

Commit ee05d0e

Browse files
committed
Compile public api so that all the updates are ensured to be correct
1 parent 8b2a219 commit ee05d0e

File tree

3 files changed

+31
-7
lines changed

3 files changed

+31
-7
lines changed

src/harness/unittests/publicApi.ts

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,34 @@
11
/// <reference path="../harness.ts" />
22

33
describe("Public APIs", () => {
4-
it("for the language service and compiler should be acknowledged when they change", () => {
5-
Harness.Baseline.runBaseline("api/typescript.d.ts", () => Harness.IO.readFile("built/local/typescript.d.ts"));
4+
function verifyApi(fileName: string) {
5+
const builtFile = `built/local/${fileName}`;
6+
const api = `api/${fileName}`;
7+
let fileContent: string;
8+
before(() => {
9+
fileContent = Harness.IO.readFile(builtFile);
10+
});
11+
12+
it("should be acknowledged when they change", () => {
13+
Harness.Baseline.runBaseline(api, () => fileContent);
14+
});
15+
16+
it("should compile", () => {
17+
const testFile: Harness.Compiler.TestFile = {
18+
unitName: builtFile,
19+
content: fileContent
20+
};
21+
const inputFiles = [testFile];
22+
const output = Harness.Compiler.compileFiles(inputFiles, [], /*harnessSettings*/ undefined, /*options*/ {}, /*currentDirectory*/ undefined);
23+
assert(!output.result.errors || !output.result.errors.length, Harness.Compiler.minimalDiagnosticsToString(output.result.errors, /*pretty*/ true));
24+
});
25+
}
26+
27+
describe("for the language service and compiler", () => {
28+
verifyApi("typescript.d.ts");
629
});
7-
it("for the language server should be acknowledged when they change", () => {
8-
Harness.Baseline.runBaseline("api/tsserverlibrary.d.ts", () => Harness.IO.readFile("built/local/tsserverlibrary.d.ts"));
30+
31+
describe("for the language server", () => {
32+
verifyApi("tsserverlibrary.d.ts");
933
});
10-
});
34+
});

src/server/project.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ namespace ts.server {
296296
}
297297
}
298298

299-
getCancellationToken() {
299+
getCancellationToken(): HostCancellationToken {
300300
return this.cancellationToken;
301301
}
302302

tests/baselines/reference/api/tsserverlibrary.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7104,7 +7104,7 @@ declare namespace ts.server {
71047104
getScriptKind(fileName: string): ScriptKind;
71057105
getScriptVersion(filename: string): string;
71067106
getScriptSnapshot(filename: string): IScriptSnapshot;
7107-
getCancellationToken(): ThrottledCancellationToken;
7107+
getCancellationToken(): HostCancellationToken;
71087108
getCurrentDirectory(): string;
71097109
getDefaultLibFileName(): string;
71107110
useCaseSensitiveFileNames(): boolean;

0 commit comments

Comments
 (0)