Skip to content

Commit 5733e40

Browse files
committed
Fix tests
1 parent af0d904 commit 5733e40

File tree

10 files changed

+53
-14
lines changed

10 files changed

+53
-14
lines changed

Diff for: src/compiler/checker.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,8 @@ namespace ts {
316316
let instantiationDepth = 0;
317317
let constraintDepth = 0;
318318
let currentNode: Node | undefined;
319-
let typeCatalog: Type[] = []; // NB: id is index + 1
319+
320+
const typeCatalog: Type[] = []; // NB: id is index + 1
320321

321322
const emptySymbols = createSymbolTable();
322323
const arrayVariances = [VarianceFlags.Covariant];

Diff for: src/compiler/sys.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1209,6 +1209,7 @@ namespace ts {
12091209
_fs.closeSync(fd);
12101210
}
12111211
catch {
1212+
// ignore
12121213
}
12131214
},
12141215
readFile,

Diff for: src/compiler/tracing.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/*@internal*/
22
/** Tracing events for the compiler. */
33
namespace ts.tracing {
4-
type writeFn = (data: string) => void;
4+
type WriteFn = (data: string) => void;
55

6-
let write: writeFn | undefined = undefined;
6+
let write: WriteFn | undefined;
77

88
/** Enables (and resets) tracing events for the compiler. */
9-
export function startTracing(w: writeFn) {
9+
export function startTracing(w: WriteFn) {
1010
write = w;
1111
write(`[\n`);
1212
}
@@ -53,7 +53,7 @@ namespace ts.tracing {
5353
};
5454
}
5555

56-
export function dumpTypes(types: readonly Type[], write: writeFn) {
56+
export function dumpTypes(types: readonly Type[], write: WriteFn) {
5757
performance.mark("beginDumpTypes");
5858

5959
const numTypes = types.length;
@@ -68,7 +68,7 @@ namespace ts.tracing {
6868
const firstFile = firstDeclaration && getSourceFileOfNode(firstDeclaration);
6969

7070
// It's slow to compute the display text, so skip it unless it's really valuable (or cheap)
71-
let display = undefined;
71+
let display: string | undefined;
7272
if ((objectFlags & ObjectFlags.Anonymous) | (type.flags & TypeFlags.Literal)) {
7373
try {
7474
display = type.checker?.typeToString(type);
@@ -123,9 +123,9 @@ namespace ts.tracing {
123123
start: indexFromOne(getLineAndCharacterOfPosition(firstFile, firstDeclaration.pos)),
124124
end: indexFromOne(getLineAndCharacterOfPosition(getSourceFileOfNode(firstDeclaration), firstDeclaration.end)),
125125
},
126-
flags: ts.Debug.formatTypeFlags(type.flags).split("|"),
126+
flags: Debug.formatTypeFlags(type.flags).split("|"),
127127
display,
128-
}
128+
};
129129

130130
write(JSON.stringify(descriptor));
131131
if (i < numTypes - 1) {

Diff for: src/harness/fakesHosts.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ namespace fakes {
3737
return true;
3838
}
3939

40-
public write(message: string) {
40+
public write(message: string, fd?: number) {
41+
assert.isUndefined(fd);
4142
this.output.push(message);
4243
}
4344

@@ -60,6 +61,15 @@ namespace fakes {
6061
this.vfs.unlinkSync(path);
6162
}
6263

64+
public openFile(_path: string, _mode: "w"): number | undefined {
65+
assert.fail("NYI");
66+
return undefined;
67+
}
68+
69+
public closeFile(_fd: number): void{
70+
assert.fail("NYI");
71+
}
72+
6373
public fileExists(path: string) {
6474
const stats = this._getStats(path);
6575
return stats ? stats.isFile() : false;

Diff for: src/harness/harnessLanguageService.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,8 @@ namespace Harness.LanguageService {
724724

725725
onMessage = ts.noop;
726726
writeMessage = ts.noop; // overridden
727-
write(message: string): void {
727+
write(message: string, fd?: number): void {
728+
assert.isUndefined(fd);
728729
this.writeMessage(message);
729730
}
730731

@@ -744,6 +745,9 @@ namespace Harness.LanguageService {
744745

745746
writeFile = ts.noop;
746747

748+
openFile = ts.returnUndefined;
749+
closeFile = ts.noop;
750+
747751
resolvePath(path: string): string {
748752
return path;
749753
}

Diff for: src/harness/virtualFileSystemWithWatch.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -1011,11 +1011,21 @@ interface Array<T> { length: number; [n: number]: T; }`
10111011
}
10121012
}
10131013

1014+
openFile(_path: string, _mode: "w"): number | undefined {
1015+
assert.fail("NYI");
1016+
return undefined;
1017+
}
1018+
1019+
closeFile(_fd: number): void {
1020+
assert.fail("NYI");
1021+
}
1022+
10141023
appendFile(path: string, content: string, options?: Partial<ReloadWatchInvokeOptions>): void {
10151024
this.modifyFile(path, this.readFile(path) + content, options);
10161025
}
10171026

1018-
write(message: string) {
1027+
write(message: string, fd?: number) {
1028+
assert.isUndefined(fd);
10191029
this.output.push(message);
10201030
}
10211031

Diff for: src/testRunner/unittests/tsserver/session.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ namespace ts.server {
77
args: [],
88
newLine: "\n",
99
useCaseSensitiveFileNames: true,
10-
write(s): void { lastWrittenToHost = s; },
10+
write(s, _fd: number): void { lastWrittenToHost = s; },
1111
readFile: returnUndefined,
1212
writeFile: noop,
13+
openFile: returnUndefined,
14+
closeFile: noop,
1315
resolvePath(): string { return undefined!; }, // TODO: GH#18217
1416
fileExists: () => false,
1517
directoryExists: () => false,

Diff for: tests/baselines/reference/api/tsserverlibrary.d.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -2053,6 +2053,7 @@ declare namespace ts {
20532053
* Gets a type checker that can be used to semantically analyze source files in the program.
20542054
*/
20552055
getTypeChecker(): TypeChecker;
2056+
getTypeCatalog(): readonly Type[];
20562057
getNodeCount(): number;
20572058
getIdentifierCount(): number;
20582059
getSymbolCount(): number;
@@ -3842,11 +3843,13 @@ declare namespace ts {
38423843
args: string[];
38433844
newLine: string;
38443845
useCaseSensitiveFileNames: boolean;
3845-
write(s: string): void;
3846+
write(s: string, fd?: number): void;
38463847
writeOutputIsTTY?(): boolean;
38473848
readFile(path: string, encoding?: string): string | undefined;
38483849
getFileSize?(path: string): number;
38493850
writeFile(path: string, data: string, writeByteOrderMark?: boolean): void;
3851+
openFile(path: string, mode: "w"): number | undefined;
3852+
closeFile(fd: number): void;
38503853
/**
38513854
* @pollingInterval - this parameter is used in polling-based watchers and ignored in watchers that
38523855
* use native OS file watching

Diff for: tests/baselines/reference/api/typescript.d.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -2053,6 +2053,7 @@ declare namespace ts {
20532053
* Gets a type checker that can be used to semantically analyze source files in the program.
20542054
*/
20552055
getTypeChecker(): TypeChecker;
2056+
getTypeCatalog(): readonly Type[];
20562057
getNodeCount(): number;
20572058
getIdentifierCount(): number;
20582059
getSymbolCount(): number;
@@ -3842,11 +3843,13 @@ declare namespace ts {
38423843
args: string[];
38433844
newLine: string;
38443845
useCaseSensitiveFileNames: boolean;
3845-
write(s: string): void;
3846+
write(s: string, fd?: number): void;
38463847
writeOutputIsTTY?(): boolean;
38473848
readFile(path: string, encoding?: string): string | undefined;
38483849
getFileSize?(path: string): number;
38493850
writeFile(path: string, data: string, writeByteOrderMark?: boolean): void;
3851+
openFile(path: string, mode: "w"): number | undefined;
3852+
closeFile(fd: number): void;
38503853
/**
38513854
* @pollingInterval - this parameter is used in polling-based watchers and ignored in watchers that
38523855
* use native OS file watching
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"compilerOptions": {
3+
"generateTrace": "./someString"
4+
}
5+
}

0 commit comments

Comments
 (0)