Skip to content

Commit 1447819

Browse files
authored
Elide line:col info in "!!! related" errors when from default lib.d.ts files (#52330)
1 parent 0c2fa39 commit 1447819

File tree

43 files changed

+80
-76
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+80
-76
lines changed

src/harness/harnessIO.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,11 @@ export namespace Compiler {
596596
.map(s => "!!! " + ts.diagnosticCategoryName(error) + " TS" + error.code + ": " + s);
597597
if (error.relatedInformation) {
598598
for (const info of error.relatedInformation) {
599-
errLines.push(`!!! related TS${info.code}${info.file ? " " + ts.formatLocation(info.file, info.start!, formatDiagnsoticHost, ts.identity) : ""}: ${ts.flattenDiagnosticMessageText(info.messageText, IO.newLine())}`);
599+
let location = info.file ? " " + ts.formatLocation(info.file, info.start!, formatDiagnsoticHost, ts.identity) : "";
600+
if (location && isDefaultLibraryFile(info.file!.fileName)) {
601+
location = location.replace(/(lib(?:.*)\.d\.ts):\d+:\d+/i, "$1:--:--");
602+
}
603+
errLines.push(`!!! related TS${info.code}${location}: ${ts.flattenDiagnosticMessageText(info.messageText, IO.newLine())}`);
600604
}
601605
}
602606
errLines.forEach(e => outputLines += (newLine() + e));

tests/baselines/reference/DateTimeFormatAndNumberFormatES2021.errors.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ tests/cases/compiler/DateTimeFormatAndNumberFormatES2021.ts(5,25): error TS2551:
1515
new Intl.NumberFormat().formatRangeToParts
1616
~~~~~~~~~~~~~~~~~~
1717
!!! error TS2551: Property 'formatRangeToParts' does not exist on type 'NumberFormat'. Did you mean 'formatToParts'?
18-
!!! related TS2728 /.ts/lib.es2018.intl.d.ts:71:9: 'formatToParts' is declared here.
18+
!!! related TS2728 /.ts/lib.es2018.intl.d.ts:--:--: 'formatToParts' is declared here.
1919
new Intl.DateTimeFormat().formatRange
2020
new Intl.DateTimeFormat().formatRangeToParts

tests/baselines/reference/asyncArrowFunction9_es2017.errors.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction9_es20
1616
!!! error TS1005: ',' expected.
1717
~~~~~~~
1818
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' must be of type 'PromiseConstructor', but here has type 'any'.
19-
!!! related TS6203 /.ts/lib.es2015.promise.d.ts:83:13: 'Promise' was also declared here.
19+
!!! related TS6203 /.ts/lib.es2015.promise.d.ts:--:--: 'Promise' was also declared here.
2020
~
2121
!!! error TS1005: ',' expected.
2222
~~

tests/baselines/reference/asyncArrowFunction9_es5.errors.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction9_es5.ts(
1616
!!! error TS1005: ',' expected.
1717
~~~~~~~
1818
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' must be of type 'PromiseConstructor', but here has type 'any'.
19-
!!! related TS6203 /.ts/lib.es2015.promise.d.ts:83:13: 'Promise' was also declared here.
19+
!!! related TS6203 /.ts/lib.es2015.promise.d.ts:--:--: 'Promise' was also declared here.
2020
~
2121
!!! error TS1005: ',' expected.
2222
~~

tests/baselines/reference/asyncArrowFunction9_es6.errors.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts(
1616
!!! error TS1005: ',' expected.
1717
~~~~~~~
1818
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' must be of type 'PromiseConstructor', but here has type 'any'.
19-
!!! related TS6203 /.ts/lib.es2015.promise.d.ts:83:13: 'Promise' was also declared here.
19+
!!! related TS6203 /.ts/lib.es2015.promise.d.ts:--:--: 'Promise' was also declared here.
2020
~
2121
!!! error TS1005: ',' expected.
2222
~~

tests/baselines/reference/baseCheck.errors.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ tests/cases/compiler/baseCheck.ts(26,9): error TS2304: Cannot find name 'x'.
2121
super(0, loc);
2222
~~~
2323
!!! error TS2552: Cannot find name 'loc'. Did you mean 'Lock'?
24-
!!! related TS2728 /.ts/lib.dom.d.ts:9319:13: 'Lock' is declared here.
24+
!!! related TS2728 /.ts/lib.dom.d.ts:--:--: 'Lock' is declared here.
2525
}
2626

2727
m() {

tests/baselines/reference/checkIndexConstraintOfJavascriptClassExpression.errors.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ tests/cases/compiler/weird.js(9,17): error TS7006: Parameter 'error' implicitly
99
someFunction(function(BaseClass) {
1010
~~~~~~~~~~~~
1111
!!! error TS2552: Cannot find name 'someFunction'. Did you mean 'Function'?
12-
!!! related TS2728 /.ts/lib.es5.d.ts:321:13: 'Function' is declared here.
12+
!!! related TS2728 /.ts/lib.es5.d.ts:--:--: 'Function' is declared here.
1313
~~~~~~~~~
1414
!!! error TS7006: Parameter 'BaseClass' implicitly has an 'any' type.
1515
'use strict';

tests/baselines/reference/destructuringParameterDeclaration4.errors.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(
4141
a1(...array2); // Error parameter type is (number|string)[]
4242
~~~~~~
4343
!!! error TS2552: Cannot find name 'array2'. Did you mean 'Array'?
44-
!!! related TS2728 /.ts/lib.es5.d.ts:1498:13: 'Array' is declared here.
44+
!!! related TS2728 /.ts/lib.es5.d.ts:--:--: 'Array' is declared here.
4545
a5([1, 2, "string", false, true]); // Error, parameter type is [any, any, [[any]]]
4646
~~~~~~~~
4747
!!! error TS2322: Type 'string' is not assignable to type '[[any]]'.

tests/baselines/reference/destructuringTuple.errors.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ tests/cases/compiler/destructuringTuple.ts(11,60): error TS2769: No overload mat
3333
!!! error TS2769: Overload 2 of 3, '(callbackfn: (previousValue: [], currentValue: number, currentIndex: number, array: number[]) => [], initialValue: []): []', gave the following error.
3434
!!! error TS2769: Type 'never[]' is not assignable to type '[]'.
3535
!!! error TS2769: Target allows only 0 element(s) but source may have more.
36-
!!! related TS6502 /.ts/lib.es5.d.ts:1463:24: The expected type comes from the return type of this signature.
37-
!!! related TS6502 /.ts/lib.es5.d.ts:1469:27: The expected type comes from the return type of this signature.
36+
!!! related TS6502 /.ts/lib.es5.d.ts:--:--: The expected type comes from the return type of this signature.
37+
!!! related TS6502 /.ts/lib.es5.d.ts:--:--: The expected type comes from the return type of this signature.
3838
~~
3939
!!! error TS2769: No overload matches this call.
4040
!!! error TS2769: Overload 1 of 2, '(...items: ConcatArray<never>[]): never[]', gave the following error.

tests/baselines/reference/errorMessageOnObjectLiteralType.errors.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ tests/cases/compiler/errorMessageOnObjectLiteralType.ts(6,8): error TS2551: Prop
1313
Object.getOwnPropertyNamess(null);
1414
~~~~~~~~~~~~~~~~~~~~
1515
!!! error TS2551: Property 'getOwnPropertyNamess' does not exist on type 'ObjectConstructor'. Did you mean 'getOwnPropertyNames'?
16-
!!! related TS2728 /.ts/lib.es5.d.ts:184:5: 'getOwnPropertyNames' is declared here.
16+
!!! related TS2728 /.ts/lib.es5.d.ts:--:--: 'getOwnPropertyNames' is declared here.

0 commit comments

Comments
 (0)