Skip to content

Commit

Permalink
noErrorTruncation affects semantic diagnostics (#36306)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajafff authored and sheetalkamat committed Jan 23, 2020
1 parent ef5573b commit 0276e7f
Show file tree
Hide file tree
Showing 3 changed files with 151 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/compiler/commandLineParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -822,6 +822,7 @@ namespace ts {
{
name: "noErrorTruncation",
type: "boolean",
affectsSemanticDiagnostics: true,
category: Diagnostics.Advanced_Options,
description: Diagnostics.Do_not_truncate_error_messages
},
Expand Down
33 changes: 33 additions & 0 deletions src/testRunner/unittests/tscWatch/programUpdates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1164,6 +1164,39 @@ foo().hello`
]
});

verifyTscWatch({
scenario,
subScenario: "updates errors when noErrorTruncation changes",
commandLineArgs: ["-w"],
sys: () => {
const aFile: File = {
path: `${projectRoot}/a.ts`,
content: `declare var v: {
reallyLongPropertyName1: string | number | boolean | object | symbol | bigint;
reallyLongPropertyName2: string | number | boolean | object | symbol | bigint;
reallyLongPropertyName3: string | number | boolean | object | symbol | bigint;
reallyLongPropertyName4: string | number | boolean | object | symbol | bigint;
reallyLongPropertyName5: string | number | boolean | object | symbol | bigint;
reallyLongPropertyName6: string | number | boolean | object | symbol | bigint;
reallyLongPropertyName7: string | number | boolean | object | symbol | bigint;
};
v === 'foo';`
};
const config: File = {
path: `${projectRoot}/tsconfig.json`,
content: JSON.stringify({ compilerOptions: {} })
};
return createWatchedSystem([aFile, config, libFile], { currentDirectory: projectRoot });
},
changes: [
sys => {
sys.writeFile(`${projectRoot}/tsconfig.json`, JSON.stringify({ compilerOptions: { noErrorTruncation: true } }));
sys.runQueuedTimeoutCallbacks();
return "Enable noErrorTruncation";
},
]
});

verifyTscWatch({
scenario,
subScenario: "updates diagnostics and emit when useDefineForClassFields changes",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/a/lib/tsc.js -w
//// [/user/username/projects/myproject/a.ts]
declare var v: {
reallyLongPropertyName1: string | number | boolean | object | symbol | bigint;
reallyLongPropertyName2: string | number | boolean | object | symbol | bigint;
reallyLongPropertyName3: string | number | boolean | object | symbol | bigint;
reallyLongPropertyName4: string | number | boolean | object | symbol | bigint;
reallyLongPropertyName5: string | number | boolean | object | symbol | bigint;
reallyLongPropertyName6: string | number | boolean | object | symbol | bigint;
reallyLongPropertyName7: string | number | boolean | object | symbol | bigint;
};
v === 'foo';

//// [/user/username/projects/myproject/tsconfig.json]
{"compilerOptions":{}}

//// [/a/lib/lib.d.ts]
/// <reference no-default-lib="true"/>
interface Boolean {}
interface Function {}
interface CallableFunction {}
interface NewableFunction {}
interface IArguments {}
interface Number { toExponential: any; }
interface Object {}
interface RegExp {}
interface String { charAt: any; }
interface Array<T> { length: number; [n: number]: T; }

//// [/user/username/projects/myproject/a.js]
v === 'foo';



Output::
>> Screen clear
12:00:21 AM - Starting compilation in watch mode...


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.


12:00:24 AM - Found 1 error. Watching for file changes.


Program root files: ["/user/username/projects/myproject/a.ts"]
Program options: {"watch":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"}
Program files::
/a/lib/lib.d.ts
/user/username/projects/myproject/a.ts

Semantic diagnostics in builder refreshed for::
/a/lib/lib.d.ts
/user/username/projects/myproject/a.ts

WatchedFiles::
/user/username/projects/myproject/tsconfig.json:
{"pollingInterval":250}
/user/username/projects/myproject/a.ts:
{"pollingInterval":250}
/a/lib/lib.d.ts:
{"pollingInterval":250}

FsWatches::

FsWatchesRecursive::
/user/username/projects/myproject/node_modules/@types:
{"fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
/user/username/projects/myproject:
{"fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}