diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 19824e6eb96..5fd321dc90a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -19045,7 +19045,7 @@ namespace ts { return getTypeOfSymbol(symbol); } if (diagnostic && symbol.valueDeclaration) { - addRelatedInfo(diagnostic, createDiagnosticForNode(symbol.valueDeclaration, Diagnostics._0_is_declared_here, symbolToString(symbol))); + addRelatedInfo(diagnostic, createDiagnosticForNode(symbol.valueDeclaration, Diagnostics._0_needs_an_explicit_type_annotation, symbolToString(symbol))); } } } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 485a969d545..bd4d56c2a9c 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2851,6 +2851,10 @@ "category": "Error", "code": 2781 }, + "'{0}' needs an explicit type annotation.": { + "category": "Message", + "code": 2782 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", diff --git a/tests/baselines/reference/assertionTypePredicates1.errors.txt b/tests/baselines/reference/assertionTypePredicates1.errors.txt index cefd25aa139..9b23370a4c9 100644 --- a/tests/baselines/reference/assertionTypePredicates1.errors.txt +++ b/tests/baselines/reference/assertionTypePredicates1.errors.txt @@ -184,7 +184,7 @@ tests/cases/conformance/controlFlow/assertionTypePredicates1.ts(149,5): error TS assert(typeof x === "string"); // Error ~~~~~~ !!! error TS2775: Assertions require every name in the call target to be declared with an explicit type annotation. -!!! related TS2728 tests/cases/conformance/controlFlow/assertionTypePredicates1.ts:144:11: 'assert' is declared here. +!!! related TS2782 tests/cases/conformance/controlFlow/assertionTypePredicates1.ts:144:11: 'assert' needs an explicit type annotation. const a = [assert]; a[0](typeof x === "string"); // Error ~~~~ @@ -193,7 +193,7 @@ tests/cases/conformance/controlFlow/assertionTypePredicates1.ts(149,5): error TS t1.assert(typeof x === "string"); // Error ~~~~~~~~~ !!! error TS2775: Assertions require every name in the call target to be declared with an explicit type annotation. -!!! related TS2728 tests/cases/conformance/controlFlow/assertionTypePredicates1.ts:148:11: 't1' is declared here. +!!! related TS2782 tests/cases/conformance/controlFlow/assertionTypePredicates1.ts:148:11: 't1' needs an explicit type annotation. const t2: Test = new Test(); t2.assert(typeof x === "string"); }