mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-12 19:31:16 -05:00
More actionable "must have annotation" message (#35839)
* Give an actionable elaboration. * Accepted baselines. * Less words. * Accepted baselines.
This commit is contained in:
committed by
GitHub
parent
f84b2d20a9
commit
78748c0a35
@@ -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)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user