fix(41965): fix error in definite assignment assertion context (#41989)

This commit is contained in:
Oleksandr T
2020-12-30 21:45:18 +02:00
committed by GitHub
parent dfe23421ba
commit e108257fb6
6 changed files with 40 additions and 6 deletions

View File

@@ -40134,7 +40134,9 @@ namespace ts {
if (node.exclamationToken && (node.parent.parent.kind !== SyntaxKind.VariableStatement || !node.type || node.initializer || node.flags & NodeFlags.Ambient)) {
const message = node.initializer
? Diagnostics.Declarations_with_initializers_cannot_also_have_definite_assignment_assertions
: Diagnostics.Declarations_with_definite_assignment_assertions_must_also_have_type_annotations;
: !node.type
? Diagnostics.Declarations_with_definite_assignment_assertions_must_also_have_type_annotations
: Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context;
return grammarErrorOnNode(node.exclamationToken, message);
}