Skip to content

Commit 0276e7f

Browse files
ajafffsheetalkamat
authored andcommitted
noErrorTruncation affects semantic diagnostics (#36306)
1 parent ef5573b commit 0276e7f

File tree

3 files changed

+151
-0
lines changed

3 files changed

+151
-0
lines changed

src/compiler/commandLineParser.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -822,6 +822,7 @@ namespace ts {
822822
{
823823
name: "noErrorTruncation",
824824
type: "boolean",
825+
affectsSemanticDiagnostics: true,
825826
category: Diagnostics.Advanced_Options,
826827
description: Diagnostics.Do_not_truncate_error_messages
827828
},

src/testRunner/unittests/tscWatch/programUpdates.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,6 +1164,39 @@ foo().hello`
11641164
]
11651165
});
11661166

1167+
verifyTscWatch({
1168+
scenario,
1169+
subScenario: "updates errors when noErrorTruncation changes",
1170+
commandLineArgs: ["-w"],
1171+
sys: () => {
1172+
const aFile: File = {
1173+
path: `${projectRoot}/a.ts`,
1174+
content: `declare var v: {
1175+
reallyLongPropertyName1: string | number | boolean | object | symbol | bigint;
1176+
reallyLongPropertyName2: string | number | boolean | object | symbol | bigint;
1177+
reallyLongPropertyName3: string | number | boolean | object | symbol | bigint;
1178+
reallyLongPropertyName4: string | number | boolean | object | symbol | bigint;
1179+
reallyLongPropertyName5: string | number | boolean | object | symbol | bigint;
1180+
reallyLongPropertyName6: string | number | boolean | object | symbol | bigint;
1181+
reallyLongPropertyName7: string | number | boolean | object | symbol | bigint;
1182+
};
1183+
v === 'foo';`
1184+
};
1185+
const config: File = {
1186+
path: `${projectRoot}/tsconfig.json`,
1187+
content: JSON.stringify({ compilerOptions: {} })
1188+
};
1189+
return createWatchedSystem([aFile, config, libFile], { currentDirectory: projectRoot });
1190+
},
1191+
changes: [
1192+
sys => {
1193+
sys.writeFile(`${projectRoot}/tsconfig.json`, JSON.stringify({ compilerOptions: { noErrorTruncation: true } }));
1194+
sys.runQueuedTimeoutCallbacks();
1195+
return "Enable noErrorTruncation";
1196+
},
1197+
]
1198+
});
1199+
11671200
verifyTscWatch({
11681201
scenario,
11691202
subScenario: "updates diagnostics and emit when useDefineForClassFields changes",
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
/a/lib/tsc.js -w
2+
//// [/user/username/projects/myproject/a.ts]
3+
declare var v: {
4+
reallyLongPropertyName1: string | number | boolean | object | symbol | bigint;
5+
reallyLongPropertyName2: string | number | boolean | object | symbol | bigint;
6+
reallyLongPropertyName3: string | number | boolean | object | symbol | bigint;
7+
reallyLongPropertyName4: string | number | boolean | object | symbol | bigint;
8+
reallyLongPropertyName5: string | number | boolean | object | symbol | bigint;
9+
reallyLongPropertyName6: string | number | boolean | object | symbol | bigint;
10+
reallyLongPropertyName7: string | number | boolean | object | symbol | bigint;
11+
};
12+
v === 'foo';
13+
14+
//// [/user/username/projects/myproject/tsconfig.json]
15+
{"compilerOptions":{}}
16+
17+
//// [/a/lib/lib.d.ts]
18+
/// <reference no-default-lib="true"/>
19+
interface Boolean {}
20+
interface Function {}
21+
interface CallableFunction {}
22+
interface NewableFunction {}
23+
interface IArguments {}
24+
interface Number { toExponential: any; }
25+
interface Object {}
26+
interface RegExp {}
27+
interface String { charAt: any; }
28+
interface Array<T> { length: number; [n: number]: T; }
29+
30+
//// [/user/username/projects/myproject/a.js]
31+
v === 'foo';
32+
33+
34+
35+
Output::
36+
>> Screen clear
37+
12:00:21 AM - Starting compilation in watch mode...
38+
39+
40+
a.ts(10,1): error TS2367: This condition will always return 'false' since the types '{ reallyLongPropertyName1: string | number | bigint | boolean | symbol | object; reallyLongPropertyName2: string | number | bigint | boolean | symbol | object; reallyLongPropertyName3: string | ... 4 more ... | object; reallyLongPropertyName4: string | ... 4 more ... | object; reallyLongPropertyName5: string | ... 4...' and 'string' have no overlap.
41+
42+
43+
12:00:24 AM - Found 1 error. Watching for file changes.
44+
45+
46+
Program root files: ["/user/username/projects/myproject/a.ts"]
47+
Program options: {"watch":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"}
48+
Program files::
49+
/a/lib/lib.d.ts
50+
/user/username/projects/myproject/a.ts
51+
52+
Semantic diagnostics in builder refreshed for::
53+
/a/lib/lib.d.ts
54+
/user/username/projects/myproject/a.ts
55+
56+
WatchedFiles::
57+
/user/username/projects/myproject/tsconfig.json:
58+
{"pollingInterval":250}
59+
/user/username/projects/myproject/a.ts:
60+
{"pollingInterval":250}
61+
/a/lib/lib.d.ts:
62+
{"pollingInterval":250}
63+
64+
FsWatches::
65+
66+
FsWatchesRecursive::
67+
/user/username/projects/myproject/node_modules/@types:
68+
{"fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
69+
/user/username/projects/myproject:
70+
{"fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
71+
72+
exitCode:: ExitStatus.undefined
73+
74+
Change:: Enable noErrorTruncation
75+
76+
//// [/user/username/projects/myproject/tsconfig.json]
77+
{"compilerOptions":{"noErrorTruncation":true}}
78+
79+
80+
Output::
81+
>> Screen clear
82+
12:00:28 AM - File change detected. Starting incremental compilation...
83+
84+
85+
a.ts(10,1): error TS2367: This condition will always return 'false' since the types '{ reallyLongPropertyName1: string | number | bigint | boolean | symbol | object; reallyLongPropertyName2: string | number | bigint | boolean | symbol | object; reallyLongPropertyName3: string | number | bigint | boolean | symbol | object; reallyLongPropertyName4: string | number | bigint | boolean | symbol | object; reallyLongPropertyName5: string | number | bigint | boolean | symbol | object; reallyLongPropertyName6: string | number | bigint | boolean | symbol | object; reallyLongPropertyName7: string | number | bigint | boolean | symbol | object; }' and 'string' have no overlap.
86+
87+
88+
12:00:29 AM - Found 1 error. Watching for file changes.
89+
90+
91+
Program root files: ["/user/username/projects/myproject/a.ts"]
92+
Program options: {"noErrorTruncation":true,"watch":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"}
93+
Program files::
94+
/a/lib/lib.d.ts
95+
/user/username/projects/myproject/a.ts
96+
97+
Semantic diagnostics in builder refreshed for::
98+
/a/lib/lib.d.ts
99+
/user/username/projects/myproject/a.ts
100+
101+
WatchedFiles::
102+
/user/username/projects/myproject/tsconfig.json:
103+
{"pollingInterval":250}
104+
/user/username/projects/myproject/a.ts:
105+
{"pollingInterval":250}
106+
/a/lib/lib.d.ts:
107+
{"pollingInterval":250}
108+
109+
FsWatches::
110+
111+
FsWatchesRecursive::
112+
/user/username/projects/myproject/node_modules/@types:
113+
{"fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
114+
/user/username/projects/myproject:
115+
{"fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
116+
117+
exitCode:: ExitStatus.undefined

0 commit comments

Comments
 (0)