@@ -35092,10 +35092,7 @@ namespace ts {
35092
35092
forEach(node.parameters, checkParameter);
35093
35093
35094
35094
// TODO(rbuckton): Should we start checking JSDoc types?
35095
- if (canHaveIllegalType(node) && node.illegalType) {
35096
- checkSourceElement(node.illegalType);
35097
- }
35098
- else if (node.type) {
35095
+ if (node.type) {
35099
35096
checkSourceElement(node.type);
35100
35097
}
35101
35098
@@ -43413,7 +43410,7 @@ namespace ts {
43413
43410
}
43414
43411
43415
43412
function checkGrammarDecorators(node: Node): boolean {
43416
- if (canHaveIllegalDecorators(node) && some(node.illegalDecorators )) {
43413
+ if (canHaveIllegalDecorators(node) && some(node.decorators )) {
43417
43414
return grammarErrorOnFirstToken(node, Diagnostics.Decorators_are_not_valid_here);
43418
43415
}
43419
43416
if (!canHaveDecorators(node) || !hasDecorators(node)) {
@@ -43437,11 +43434,6 @@ namespace ts {
43437
43434
}
43438
43435
43439
43436
function checkGrammarModifiers(node: HasModifiers | HasIllegalModifiers): boolean {
43440
- if (canHaveIllegalModifiers(node)) {
43441
- const firstModifier = firstOrUndefined(node.illegalModifiers);
43442
- return !!firstModifier && grammarErrorOnNode(firstModifier, Diagnostics.Modifiers_cannot_appear_here);
43443
- }
43444
-
43445
43437
const quickResult = reportObviousModifierErrors(node);
43446
43438
if (quickResult !== undefined) {
43447
43439
return quickResult;
@@ -43721,15 +43713,15 @@ namespace ts {
43721
43713
* true | false: Early return this value from checkGrammarModifiers.
43722
43714
* undefined: Need to do full checking on the modifiers.
43723
43715
*/
43724
- function reportObviousModifierErrors(node: HasModifiers): boolean | undefined {
43716
+ function reportObviousModifierErrors(node: HasModifiers | HasIllegalModifiers ): boolean | undefined {
43725
43717
return !node.modifiers
43726
43718
? false
43727
43719
: shouldReportBadModifier(node)
43728
43720
? grammarErrorOnFirstToken(node, Diagnostics.Modifiers_cannot_appear_here)
43729
43721
: undefined;
43730
43722
}
43731
43723
43732
- function shouldReportBadModifier(node: HasModifiers): boolean {
43724
+ function shouldReportBadModifier(node: HasModifiers | HasIllegalModifiers ): boolean {
43733
43725
switch (node.kind) {
43734
43726
case SyntaxKind.GetAccessor:
43735
43727
case SyntaxKind.SetAccessor:
@@ -43749,6 +43741,13 @@ namespace ts {
43749
43741
case SyntaxKind.Parameter:
43750
43742
case SyntaxKind.TypeParameter:
43751
43743
return false;
43744
+ case SyntaxKind.ClassStaticBlockDeclaration:
43745
+ case SyntaxKind.PropertyAssignment:
43746
+ case SyntaxKind.ShorthandPropertyAssignment:
43747
+ case SyntaxKind.NamespaceExportDeclaration:
43748
+ case SyntaxKind.FunctionType:
43749
+ case SyntaxKind.MissingDeclaration:
43750
+ return true;
43752
43751
default:
43753
43752
if (node.parent.kind === SyntaxKind.ModuleBlock || node.parent.kind === SyntaxKind.SourceFile) {
43754
43753
return false;
@@ -44122,9 +44121,8 @@ namespace ts {
44122
44121
}
44123
44122
}
44124
44123
}
44125
-
44126
- if (canHaveIllegalModifiers(prop) && prop.illegalModifiers) {
44127
- for (const mod of prop.illegalModifiers) {
44124
+ else if (canHaveIllegalModifiers(prop) && prop.modifiers) {
44125
+ for (const mod of prop.modifiers) {
44128
44126
grammarErrorOnNode(mod, Diagnostics._0_modifier_cannot_be_used_here, getTextOfNode(mod));
44129
44127
}
44130
44128
}
@@ -44140,11 +44138,10 @@ namespace ts {
44140
44138
let currentKind: DeclarationMeaning;
44141
44139
switch (prop.kind) {
44142
44140
case SyntaxKind.ShorthandPropertyAssignment:
44143
- checkGrammarForInvalidExclamationToken(prop.illegalExclamationToken, Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context);
44144
- // falls through
44145
44141
case SyntaxKind.PropertyAssignment:
44146
44142
// Grammar checking for computedPropertyName and shorthandPropertyAssignment
44147
- checkGrammarForInvalidQuestionMark(prop.illegalQuestionToken, Diagnostics.An_object_member_cannot_be_declared_optional);
44143
+ checkGrammarForInvalidExclamationToken(prop.exclamationToken, Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context);
44144
+ checkGrammarForInvalidQuestionMark(prop.questionToken, Diagnostics.An_object_member_cannot_be_declared_optional);
44148
44145
if (name.kind === SyntaxKind.NumericLiteral) {
44149
44146
checkGrammarNumericLiteral(name);
44150
44147
}
@@ -44376,7 +44373,7 @@ namespace ts {
44376
44373
return grammarErrorOnNode(accessor.body, Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts);
44377
44374
}
44378
44375
}
44379
- if (accessor.illegalTypeParameters ) {
44376
+ if (accessor.typeParameters ) {
44380
44377
return grammarErrorOnNode(accessor.name, Diagnostics.An_accessor_cannot_have_type_parameters);
44381
44378
}
44382
44379
if (!doesAccessorHaveCorrectParameterCount(accessor)) {
@@ -44386,7 +44383,7 @@ namespace ts {
44386
44383
Diagnostics.A_set_accessor_must_have_exactly_one_parameter);
44387
44384
}
44388
44385
if (accessor.kind === SyntaxKind.SetAccessor) {
44389
- if (accessor.illegalType ) {
44386
+ if (accessor.type ) {
44390
44387
return grammarErrorOnNode(accessor.name, Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation);
44391
44388
}
44392
44389
const parameter = Debug.checkDefined(getSetAccessorValueParameter(accessor), "Return value does not match parameter count assertion.");
@@ -44487,7 +44484,7 @@ namespace ts {
44487
44484
else if (checkGrammarForInvalidQuestionMark(node.questionToken, Diagnostics.An_object_member_cannot_be_declared_optional)) {
44488
44485
return true;
44489
44486
}
44490
- else if (checkGrammarForInvalidExclamationToken(node.illegalExclamationToken , Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context)) {
44487
+ else if (checkGrammarForInvalidExclamationToken(node.exclamationToken , Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context)) {
44491
44488
return true;
44492
44489
}
44493
44490
else if (node.body === undefined) {
@@ -44616,7 +44613,7 @@ namespace ts {
44616
44613
}
44617
44614
44618
44615
function checkAmbientInitializer(node: VariableDeclaration | PropertyDeclaration | PropertySignature) {
44619
- const initializer = hasOnlyExpressionInitializer( node) ? node .initializer : node.illegalInitializer ;
44616
+ const initializer = node.initializer;
44620
44617
if (initializer) {
44621
44618
const isInvalidInitializer = !(
44622
44619
isStringOrNumberLiteralExpression(initializer) ||
@@ -44813,15 +44810,15 @@ namespace ts {
44813
44810
44814
44811
function checkGrammarConstructorTypeParameters(node: ConstructorDeclaration) {
44815
44812
const jsdocTypeParameters = isInJSFile(node) ? getJSDocTypeParameterDeclarations(node) : undefined;
44816
- const range = node.illegalTypeParameters || jsdocTypeParameters && firstOrUndefined(jsdocTypeParameters);
44813
+ const range = node.typeParameters || jsdocTypeParameters && firstOrUndefined(jsdocTypeParameters);
44817
44814
if (range) {
44818
44815
const pos = range.pos === range.end ? range.pos : skipTrivia(getSourceFileOfNode(node).text, range.pos);
44819
44816
return grammarErrorAtPos(node, pos, range.end - pos, Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration);
44820
44817
}
44821
44818
}
44822
44819
44823
44820
function checkGrammarConstructorTypeAnnotation(node: ConstructorDeclaration) {
44824
- const type = node.illegalType || getEffectiveReturnTypeNode(node);
44821
+ const type = node.type || getEffectiveReturnTypeNode(node);
44825
44822
if (type) {
44826
44823
return grammarErrorOnNode(type, Diagnostics.Type_annotation_cannot_appear_on_a_constructor_declaration);
44827
44824
}
@@ -44851,8 +44848,8 @@ namespace ts {
44851
44848
44852
44849
// Interfaces cannot contain property declarations
44853
44850
Debug.assertNode(node, isPropertySignature);
44854
- if (node.illegalInitializer ) {
44855
- return grammarErrorOnNode(node.illegalInitializer , Diagnostics.An_interface_property_cannot_have_an_initializer);
44851
+ if (node.initializer ) {
44852
+ return grammarErrorOnNode(node.initializer , Diagnostics.An_interface_property_cannot_have_an_initializer);
44856
44853
}
44857
44854
}
44858
44855
else if (isTypeLiteralNode(node.parent)) {
@@ -44861,8 +44858,8 @@ namespace ts {
44861
44858
}
44862
44859
// Type literals cannot contain property declarations
44863
44860
Debug.assertNode(node, isPropertySignature);
44864
- if (node.illegalInitializer ) {
44865
- return grammarErrorOnNode(node.illegalInitializer , Diagnostics.A_type_literal_property_cannot_have_an_initializer);
44861
+ if (node.initializer ) {
44862
+ return grammarErrorOnNode(node.initializer , Diagnostics.A_type_literal_property_cannot_have_an_initializer);
44866
44863
}
44867
44864
}
44868
44865
0 commit comments