Skip to content

Commit 4da9fc5

Browse files
committed
Add test case when the errors are not refreshed if global file is deleted
Testcase for #36728
1 parent 221a2ae commit 4da9fc5

File tree

3 files changed

+260
-0
lines changed

3 files changed

+260
-0
lines changed

src/testRunner/unittests/tscWatch/incremental.ts

+11
Original file line numberDiff line numberDiff line change
@@ -265,5 +265,16 @@ export interface A {
265265
}
266266
`)
267267
});
268+
269+
verifyIncrementalWatchEmit({
270+
subScenario: "when file with ambient global declaration file is deleted",
271+
files: () => [
272+
{ path: libFile.path, content: libContent },
273+
{ path: `${project}/globals.d.ts`, content: `declare namespace Config { const value: string;} ` },
274+
{ path: `${project}/index.ts`, content: `console.log(Config.value);` },
275+
{ path: configFile.path, content: JSON.stringify({ compilerOptions: { incremental: true, } }) }
276+
],
277+
modifyFs: host => host.deleteFile(`${project}/globals.d.ts`)
278+
});
268279
});
269280
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
/a/lib/tsc.js -i
2+
//// [/a/lib/lib.d.ts]
3+
/// <reference no-default-lib="true"/>
4+
interface Boolean {}
5+
interface Function {}
6+
interface CallableFunction {}
7+
interface NewableFunction {}
8+
interface IArguments {}
9+
interface Number { toExponential: any; }
10+
interface Object {}
11+
interface RegExp {}
12+
interface String { charAt: any; }
13+
interface Array<T> { length: number; [n: number]: T; }
14+
interface ReadonlyArray<T> {}
15+
declare const console: { log(msg: any): void; };
16+
17+
//// [/users/username/projects/project/globals.d.ts]
18+
declare namespace Config { const value: string;}
19+
20+
//// [/users/username/projects/project/index.ts]
21+
console.log(Config.value);
22+
23+
//// [/users/username/projects/project/tsconfig.json]
24+
{"compilerOptions":{"incremental":true}}
25+
26+
//// [/users/username/projects/project/index.js]
27+
console.log(Config.value);
28+
29+
30+
//// [/users/username/projects/project/tsconfig.tsbuildinfo]
31+
{
32+
"program": {
33+
"fileInfos": {
34+
"../../../../a/lib/lib.d.ts": {
35+
"version": "3858781397-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };",
36+
"signature": "3858781397-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };"
37+
},
38+
"./globals.d.ts": {
39+
"version": "-6314871648-declare namespace Config { const value: string;} ",
40+
"signature": "-6314871648-declare namespace Config { const value: string;} "
41+
},
42+
"./index.ts": {
43+
"version": "5371023861-console.log(Config.value);",
44+
"signature": "5381-"
45+
}
46+
},
47+
"options": {
48+
"incremental": true,
49+
"configFilePath": "./tsconfig.json"
50+
},
51+
"referencedMap": {},
52+
"exportedModulesMap": {},
53+
"semanticDiagnosticsPerFile": [
54+
"../../../../a/lib/lib.d.ts",
55+
"./globals.d.ts",
56+
"./index.ts"
57+
]
58+
},
59+
"version": "FakeTSVersion"
60+
}
61+
62+
63+
Output::
64+
65+
66+
Program root files: ["/users/username/projects/project/globals.d.ts","/users/username/projects/project/index.ts"]
67+
Program options: {"incremental":true,"configFilePath":"/users/username/projects/project/tsconfig.json"}
68+
Program files::
69+
/a/lib/lib.d.ts
70+
/users/username/projects/project/globals.d.ts
71+
/users/username/projects/project/index.ts
72+
73+
Semantic diagnostics in builder refreshed for::
74+
/a/lib/lib.d.ts
75+
/users/username/projects/project/globals.d.ts
76+
/users/username/projects/project/index.ts
77+
78+
WatchedFiles::
79+
80+
FsWatches::
81+
82+
FsWatchesRecursive::
83+
84+
exitCode:: ExitStatus.Success
85+
86+
Change::
87+
88+
//// [/users/username/projects/project/globals.d.ts] deleted
89+
90+
Output::
91+
92+
93+
Program root files: ["/users/username/projects/project/index.ts"]
94+
Program options: {"incremental":true,"configFilePath":"/users/username/projects/project/tsconfig.json"}
95+
Program files::
96+
/a/lib/lib.d.ts
97+
/users/username/projects/project/index.ts
98+
99+
Semantic diagnostics in builder refreshed for::
100+
101+
WatchedFiles::
102+
103+
FsWatches::
104+
105+
FsWatchesRecursive::
106+
107+
exitCode:: ExitStatus.Success
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
/a/lib/tsc.js -w
2+
//// [/a/lib/lib.d.ts]
3+
/// <reference no-default-lib="true"/>
4+
interface Boolean {}
5+
interface Function {}
6+
interface CallableFunction {}
7+
interface NewableFunction {}
8+
interface IArguments {}
9+
interface Number { toExponential: any; }
10+
interface Object {}
11+
interface RegExp {}
12+
interface String { charAt: any; }
13+
interface Array<T> { length: number; [n: number]: T; }
14+
interface ReadonlyArray<T> {}
15+
declare const console: { log(msg: any): void; };
16+
17+
//// [/users/username/projects/project/globals.d.ts]
18+
declare namespace Config { const value: string;}
19+
20+
//// [/users/username/projects/project/index.ts]
21+
console.log(Config.value);
22+
23+
//// [/users/username/projects/project/tsconfig.json]
24+
{"compilerOptions":{"incremental":true}}
25+
26+
//// [/users/username/projects/project/index.js]
27+
console.log(Config.value);
28+
29+
30+
//// [/users/username/projects/project/tsconfig.tsbuildinfo]
31+
{
32+
"program": {
33+
"fileInfos": {
34+
"../../../../a/lib/lib.d.ts": {
35+
"version": "3858781397-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };",
36+
"signature": "3858781397-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };"
37+
},
38+
"./globals.d.ts": {
39+
"version": "-6314871648-declare namespace Config { const value: string;} ",
40+
"signature": "-6314871648-declare namespace Config { const value: string;} "
41+
},
42+
"./index.ts": {
43+
"version": "5371023861-console.log(Config.value);",
44+
"signature": "5381-"
45+
}
46+
},
47+
"options": {
48+
"incremental": true,
49+
"watch": true,
50+
"configFilePath": "./tsconfig.json"
51+
},
52+
"referencedMap": {},
53+
"exportedModulesMap": {},
54+
"semanticDiagnosticsPerFile": [
55+
"../../../../a/lib/lib.d.ts",
56+
"./globals.d.ts",
57+
"./index.ts"
58+
]
59+
},
60+
"version": "FakeTSVersion"
61+
}
62+
63+
64+
Output::
65+
>> Screen clear
66+
[12:00:23 AM] Starting compilation in watch mode...
67+
68+
69+
[12:00:28 AM] Found 0 errors. Watching for file changes.
70+
71+
72+
73+
Program root files: ["/users/username/projects/project/globals.d.ts","/users/username/projects/project/index.ts"]
74+
Program options: {"incremental":true,"watch":true,"configFilePath":"/users/username/projects/project/tsconfig.json"}
75+
Program files::
76+
/a/lib/lib.d.ts
77+
/users/username/projects/project/globals.d.ts
78+
/users/username/projects/project/index.ts
79+
80+
Semantic diagnostics in builder refreshed for::
81+
/a/lib/lib.d.ts
82+
/users/username/projects/project/globals.d.ts
83+
/users/username/projects/project/index.ts
84+
85+
WatchedFiles::
86+
/users/username/projects/project/tsconfig.json:
87+
{"fileName":"/users/username/projects/project/tsconfig.json","pollingInterval":250}
88+
/users/username/projects/project/globals.d.ts:
89+
{"fileName":"/users/username/projects/project/globals.d.ts","pollingInterval":250}
90+
/users/username/projects/project/index.ts:
91+
{"fileName":"/users/username/projects/project/index.ts","pollingInterval":250}
92+
/a/lib/lib.d.ts:
93+
{"fileName":"/a/lib/lib.d.ts","pollingInterval":250}
94+
95+
FsWatches::
96+
97+
FsWatchesRecursive::
98+
/users/username/projects/project/node_modules/@types:
99+
{"directoryName":"/users/username/projects/project/node_modules/@types","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
100+
/users/username/projects/project:
101+
{"directoryName":"/users/username/projects/project","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
102+
103+
exitCode:: ExitStatus.undefined
104+
105+
Change::
106+
107+
//// [/users/username/projects/project/globals.d.ts] deleted
108+
109+
Output::
110+
>> Screen clear
111+
[12:00:30 AM] Starting compilation in watch mode...
112+
113+
114+
[12:00:31 AM] Found 0 errors. Watching for file changes.
115+
116+
117+
118+
Program root files: ["/users/username/projects/project/index.ts"]
119+
Program options: {"incremental":true,"watch":true,"configFilePath":"/users/username/projects/project/tsconfig.json"}
120+
Program files::
121+
/a/lib/lib.d.ts
122+
/users/username/projects/project/index.ts
123+
124+
Semantic diagnostics in builder refreshed for::
125+
126+
WatchedFiles::
127+
/users/username/projects/project/tsconfig.json:
128+
{"fileName":"/users/username/projects/project/tsconfig.json","pollingInterval":250}
129+
/users/username/projects/project/index.ts:
130+
{"fileName":"/users/username/projects/project/index.ts","pollingInterval":250}
131+
/a/lib/lib.d.ts:
132+
{"fileName":"/a/lib/lib.d.ts","pollingInterval":250}
133+
134+
FsWatches::
135+
136+
FsWatchesRecursive::
137+
/users/username/projects/project/node_modules/@types:
138+
{"directoryName":"/users/username/projects/project/node_modules/@types","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
139+
/users/username/projects/project:
140+
{"directoryName":"/users/username/projects/project","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
141+
142+
exitCode:: ExitStatus.undefined

0 commit comments

Comments
 (0)