Skip to content

Commit 010ffdc

Browse files
author
Vincent Boivin
authored
New error format (microsoft#40974)
1 parent fe7ec1e commit 010ffdc

File tree

4 files changed

+38
-52
lines changed

4 files changed

+38
-52
lines changed

src/compiler/checker.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25916,18 +25916,18 @@ namespace ts {
2591625916
relatedInfo = createDiagnosticForNode(propNode, Diagnostics.Did_you_forget_to_use_await);
2591725917
}
2591825918
else {
25919-
const suggestion = getSuggestedSymbolForNonexistentProperty(propNode, containingType);
25920-
if (suggestion !== undefined) {
25921-
const suggestedName = symbolName(suggestion);
25922-
errorInfo = chainDiagnosticMessages(errorInfo, Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, declarationNameToString(propNode), typeToString(containingType), suggestedName);
25923-
relatedInfo = suggestion.valueDeclaration && createDiagnosticForNode(suggestion.valueDeclaration, Diagnostics._0_is_declared_here, suggestedName);
25919+
const missingProperty = declarationNameToString(propNode);
25920+
const container = typeToString(containingType);
25921+
const libSuggestion = getSuggestedLibForNonExistentProperty(missingProperty, containingType);
25922+
if (libSuggestion !== undefined) {
25923+
errorInfo = chainDiagnosticMessages(errorInfo, Diagnostics.Property_0_does_not_exist_on_type_1_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2_or_later, missingProperty, container, libSuggestion);
2592425924
}
2592525925
else {
25926-
const missingProperty = declarationNameToString(propNode);
25927-
const container = typeToString(containingType);
25928-
const lib = getSuggestedLibForNonExistentProperty(missingProperty, containingType);
25929-
if (lib) {
25930-
errorInfo = chainDiagnosticMessages(errorInfo, Diagnostics.Property_0_does_not_exist_on_type_1_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2_or_later, missingProperty, container, lib);
25926+
const suggestion = getSuggestedSymbolForNonexistentProperty(propNode, containingType);
25927+
if (suggestion !== undefined) {
25928+
const suggestedName = symbolName(suggestion);
25929+
errorInfo = chainDiagnosticMessages(errorInfo, Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, missingProperty, container, suggestedName);
25930+
relatedInfo = suggestion.valueDeclaration && createDiagnosticForNode(suggestion.valueDeclaration, Diagnostics._0_is_declared_here, suggestedName);
2593125931
}
2593225932
else {
2593325933
errorInfo = chainDiagnosticMessages(elaborateNeverIntersection(errorInfo, containingType), Diagnostics.Property_0_does_not_exist_on_type_1, missingProperty, container);

tests/baselines/reference/doYouNeedToChangeYourTargetLibraryES2015.errors.txt

Lines changed: 24 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2015.ts(25,30): error T
2020
tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2015.ts(26,40): error TS2550: Property 'from' does not exist on type 'ArrayConstructor'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2015' or later.
2121
tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2015.ts(27,38): error TS2550: Property 'of' does not exist on type 'ArrayConstructor'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2015' or later.
2222
tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2015.ts(28,44): error TS2550: Property 'assign' does not exist on type 'ObjectConstructor'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2015' or later.
23-
tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2015.ts(29,59): error TS2551: Property 'getOwnPropertySymbols' does not exist on type 'ObjectConstructor'. Did you mean 'getOwnPropertyNames'?
23+
tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2015.ts(29,59): error TS2550: Property 'getOwnPropertySymbols' does not exist on type 'ObjectConstructor'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2015' or later.
2424
tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2015.ts(31,40): error TS2550: Property 'is' does not exist on type 'ObjectConstructor'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2015' or later.
25-
tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2015.ts(32,52): error TS2551: Property 'setPrototypeOf' does not exist on type 'ObjectConstructor'. Did you mean 'getPrototypeOf'?
25+
tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2015.ts(32,52): error TS2550: Property 'setPrototypeOf' does not exist on type 'ObjectConstructor'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2015' or later.
2626
tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2015.ts(33,46): error TS2550: Property 'isFinite' does not exist on type 'NumberConstructor'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2015' or later.
2727
tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2015.ts(34,47): error TS2550: Property 'isInteger' does not exist on type 'NumberConstructor'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2015' or later.
2828
tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2015.ts(35,43): error TS2550: Property 'isNaN' does not exist on type 'NumberConstructor'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2015' or later.
@@ -31,20 +31,20 @@ tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2015.ts(37,48): error T
3131
tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2015.ts(38,46): error TS2550: Property 'parseInt' does not exist on type 'NumberConstructor'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2015' or later.
3232
tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2015.ts(39,28): error TS2550: Property 'clz32' does not exist on type 'Math'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2015' or later.
3333
tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2015.ts(40,27): error TS2550: Property 'imul' does not exist on type 'Math'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2015' or later.
34-
tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2015.ts(41,27): error TS2551: Property 'sign' does not exist on type 'Math'. Did you mean 'sin'?
35-
tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2015.ts(42,28): error TS2551: Property 'log10' does not exist on type 'Math'. Did you mean 'LOG10E'?
36-
tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2015.ts(43,27): error TS2551: Property 'log2' does not exist on type 'Math'. Did you mean 'LOG2E'?
34+
tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2015.ts(41,27): error TS2550: Property 'sign' does not exist on type 'Math'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2015' or later.
35+
tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2015.ts(42,28): error TS2550: Property 'log10' does not exist on type 'Math'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2015' or later.
36+
tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2015.ts(43,27): error TS2550: Property 'log2' does not exist on type 'Math'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2015' or later.
3737
tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2015.ts(44,28): error TS2550: Property 'log1p' does not exist on type 'Math'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2015' or later.
3838
tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2015.ts(45,28): error TS2550: Property 'expm1' does not exist on type 'Math'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2015' or later.
39-
tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2015.ts(46,27): error TS2551: Property 'cosh' does not exist on type 'Math'. Did you mean 'cos'?
40-
tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2015.ts(47,27): error TS2551: Property 'sinh' does not exist on type 'Math'. Did you mean 'sin'?
41-
tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2015.ts(48,27): error TS2551: Property 'tanh' does not exist on type 'Math'. Did you mean 'tan'?
42-
tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2015.ts(49,28): error TS2551: Property 'acosh' does not exist on type 'Math'. Did you mean 'acos'?
43-
tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2015.ts(50,28): error TS2551: Property 'asinh' does not exist on type 'Math'. Did you mean 'asin'?
44-
tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2015.ts(51,28): error TS2551: Property 'atanh' does not exist on type 'Math'. Did you mean 'atan'?
39+
tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2015.ts(46,27): error TS2550: Property 'cosh' does not exist on type 'Math'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2015' or later.
40+
tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2015.ts(47,27): error TS2550: Property 'sinh' does not exist on type 'Math'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2015' or later.
41+
tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2015.ts(48,27): error TS2550: Property 'tanh' does not exist on type 'Math'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2015' or later.
42+
tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2015.ts(49,28): error TS2550: Property 'acosh' does not exist on type 'Math'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2015' or later.
43+
tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2015.ts(50,28): error TS2550: Property 'asinh' does not exist on type 'Math'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2015' or later.
44+
tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2015.ts(51,28): error TS2550: Property 'atanh' does not exist on type 'Math'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2015' or later.
4545
tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2015.ts(52,28): error TS2550: Property 'hypot' does not exist on type 'Math'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2015' or later.
4646
tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2015.ts(53,28): error TS2550: Property 'trunc' does not exist on type 'Math'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2015' or later.
47-
tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2015.ts(54,29): error TS2551: Property 'fround' does not exist on type 'Math'. Did you mean 'round'?
47+
tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2015.ts(54,29): error TS2550: Property 'fround' does not exist on type 'Math'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2015' or later.
4848
tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2015.ts(55,27): error TS2550: Property 'cbrt' does not exist on type 'Math'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2015' or later.
4949
tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2015.ts(56,16): error TS2583: Cannot find name 'Map'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2015' or later.
5050
tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2015.ts(57,16): error TS2583: Cannot find name 'Set'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2015' or later.
@@ -159,16 +159,14 @@ tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2015.ts(91,34): error T
159159
!!! error TS2550: Property 'assign' does not exist on type 'ObjectConstructor'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2015' or later.
160160
const testObjectConstructorGetOwnPropertySymbols = Object.getOwnPropertySymbols({});
161161
~~~~~~~~~~~~~~~~~~~~~
162-
!!! error TS2551: Property 'getOwnPropertySymbols' does not exist on type 'ObjectConstructor'. Did you mean 'getOwnPropertyNames'?
163-
!!! related TS2728 /.ts/lib.es5.d.ts:179:5: 'getOwnPropertyNames' is declared here.
162+
!!! error TS2550: Property 'getOwnPropertySymbols' does not exist on type 'ObjectConstructor'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2015' or later.
164163
const testObjectConstructorKeys = Object.keys({});
165164
const testObjectConstructorIs = Object.is({}, {});
166165
~~
167166
!!! error TS2550: Property 'is' does not exist on type 'ObjectConstructor'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2015' or later.
168167
const testObjectConstructorSetPrototypeOf = Object.setPrototypeOf({}, {});
169168
~~~~~~~~~~~~~~
170-
!!! error TS2551: Property 'setPrototypeOf' does not exist on type 'ObjectConstructor'. Did you mean 'getPrototypeOf'?
171-
!!! related TS2728 /.ts/lib.es5.d.ts:164:5: 'getPrototypeOf' is declared here.
169+
!!! error TS2550: Property 'setPrototypeOf' does not exist on type 'ObjectConstructor'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2015' or later.
172170
const testNumberConstructorIsFinite = Number.isFinite(0);
173171
~~~~~~~~
174172
!!! error TS2550: Property 'isFinite' does not exist on type 'NumberConstructor'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2015' or later.
@@ -195,16 +193,13 @@ tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2015.ts(91,34): error T
195193
!!! error TS2550: Property 'imul' does not exist on type 'Math'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2015' or later.
196194
const testMathSign = Math.sign(0);
197195
~~~~
198-
!!! error TS2551: Property 'sign' does not exist on type 'Math'. Did you mean 'sin'?
199-
!!! related TS2728 /.ts/lib.es5.d.ts:713:5: 'sin' is declared here.
196+
!!! error TS2550: Property 'sign' does not exist on type 'Math'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2015' or later.
200197
const testMathLog10 = Math.log10(0);
201198
~~~~~
202-
!!! error TS2551: Property 'log10' does not exist on type 'Math'. Did you mean 'LOG10E'?
203-
!!! related TS2728 /.ts/lib.es5.d.ts:627:14: 'LOG10E' is declared here.
199+
!!! error TS2550: Property 'log10' does not exist on type 'Math'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2015' or later.
204200
const testMathLog2 = Math.log2(0);
205201
~~~~
206-
!!! error TS2551: Property 'log2' does not exist on type 'Math'. Did you mean 'LOG2E'?
207-
!!! related TS2728 /.ts/lib.es5.d.ts:625:14: 'LOG2E' is declared here.
202+
!!! error TS2550: Property 'log2' does not exist on type 'Math'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2015' or later.
208203
const testMathLog1p = Math.log1p(0);
209204
~~~~~
210205
!!! error TS2550: Property 'log1p' does not exist on type 'Math'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2015' or later.
@@ -213,28 +208,22 @@ tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2015.ts(91,34): error T
213208
!!! error TS2550: Property 'expm1' does not exist on type 'Math'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2015' or later.
214209
const testMathCosh = Math.cosh(0);
215210
~~~~
216-
!!! error TS2551: Property 'cosh' does not exist on type 'Math'. Did you mean 'cos'?
217-
!!! related TS2728 /.ts/lib.es5.d.ts:670:5: 'cos' is declared here.
211+
!!! error TS2550: Property 'cosh' does not exist on type 'Math'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2015' or later.
218212
const testMathSinh = Math.sinh(0);
219213
~~~~
220-
!!! error TS2551: Property 'sinh' does not exist on type 'Math'. Did you mean 'sin'?
221-
!!! related TS2728 /.ts/lib.es5.d.ts:713:5: 'sin' is declared here.
214+
!!! error TS2550: Property 'sinh' does not exist on type 'Math'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2015' or later.
222215
const testMathTanh = Math.tanh(0);
223216
~~~~
224-
!!! error TS2551: Property 'tanh' does not exist on type 'Math'. Did you mean 'tan'?
225-
!!! related TS2728 /.ts/lib.es5.d.ts:723:5: 'tan' is declared here.
217+
!!! error TS2550: Property 'tanh' does not exist on type 'Math'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2015' or later.
226218
const testMathAcosh = Math.acosh(0);
227219
~~~~~
228-
!!! error TS2551: Property 'acosh' does not exist on type 'Math'. Did you mean 'acos'?
229-
!!! related TS2728 /.ts/lib.es5.d.ts:644:5: 'acos' is declared here.
220+
!!! error TS2550: Property 'acosh' does not exist on type 'Math'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2015' or later.
230221
const testMathAsinh = Math.asinh(0);
231222
~~~~~
232-
!!! error TS2551: Property 'asinh' does not exist on type 'Math'. Did you mean 'asin'?
233-
!!! related TS2728 /.ts/lib.es5.d.ts:649:5: 'asin' is declared here.
223+
!!! error TS2550: Property 'asinh' does not exist on type 'Math'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2015' or later.
234224
const testMathAtanh = Math.atanh(0);
235225
~~~~~
236-
!!! error TS2551: Property 'atanh' does not exist on type 'Math'. Did you mean 'atan'?
237-
!!! related TS2728 /.ts/lib.es5.d.ts:654:5: 'atan' is declared here.
226+
!!! error TS2550: Property 'atanh' does not exist on type 'Math'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2015' or later.
238227
const testMathHypot = Math.hypot(0,0);
239228
~~~~~
240229
!!! error TS2550: Property 'hypot' does not exist on type 'Math'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2015' or later.
@@ -243,8 +232,7 @@ tests/cases/compiler/doYouNeedToChangeYourTargetLibraryES2015.ts(91,34): error T
243232
!!! error TS2550: Property 'trunc' does not exist on type 'Math'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2015' or later.
244233
const testMathFround = Math.fround(0);
245234
~~~~~~
246-
!!! error TS2551: Property 'fround' does not exist on type 'Math'. Did you mean 'round'?
247-
!!! related TS2728 /.ts/lib.es5.d.ts:708:5: 'round' is declared here.
235+
!!! error TS2550: Property 'fround' does not exist on type 'Math'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2015' or later.
248236
const testMathCbrt = Math.cbrt(0);
249237
~~~~
250238
!!! error TS2550: Property 'cbrt' does not exist on type 'Math'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2015' or later.

0 commit comments

Comments
 (0)