@@ -35092,10 +35092,7 @@ namespace ts {
3509235092 forEach(node.parameters, checkParameter);
3509335093
3509435094 // 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) {
3509935096 checkSourceElement(node.type);
3510035097 }
3510135098
@@ -43413,7 +43410,7 @@ namespace ts {
4341343410 }
4341443411
4341543412 function checkGrammarDecorators(node: Node): boolean {
43416- if (canHaveIllegalDecorators(node) && some(node.illegalDecorators )) {
43413+ if (canHaveIllegalDecorators(node) && some(node.decorators )) {
4341743414 return grammarErrorOnFirstToken(node, Diagnostics.Decorators_are_not_valid_here);
4341843415 }
4341943416 if (!canHaveDecorators(node) || !hasDecorators(node)) {
@@ -43437,11 +43434,6 @@ namespace ts {
4343743434 }
4343843435
4343943436 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-
4344543437 const quickResult = reportObviousModifierErrors(node);
4344643438 if (quickResult !== undefined) {
4344743439 return quickResult;
@@ -43721,15 +43713,15 @@ namespace ts {
4372143713 * true | false: Early return this value from checkGrammarModifiers.
4372243714 * undefined: Need to do full checking on the modifiers.
4372343715 */
43724- function reportObviousModifierErrors(node: HasModifiers): boolean | undefined {
43716+ function reportObviousModifierErrors(node: HasModifiers | HasIllegalModifiers ): boolean | undefined {
4372543717 return !node.modifiers
4372643718 ? false
4372743719 : shouldReportBadModifier(node)
4372843720 ? grammarErrorOnFirstToken(node, Diagnostics.Modifiers_cannot_appear_here)
4372943721 : undefined;
4373043722 }
4373143723
43732- function shouldReportBadModifier(node: HasModifiers): boolean {
43724+ function shouldReportBadModifier(node: HasModifiers | HasIllegalModifiers ): boolean {
4373343725 switch (node.kind) {
4373443726 case SyntaxKind.GetAccessor:
4373543727 case SyntaxKind.SetAccessor:
@@ -43749,6 +43741,13 @@ namespace ts {
4374943741 case SyntaxKind.Parameter:
4375043742 case SyntaxKind.TypeParameter:
4375143743 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;
4375243751 default:
4375343752 if (node.parent.kind === SyntaxKind.ModuleBlock || node.parent.kind === SyntaxKind.SourceFile) {
4375443753 return false;
@@ -44122,11 +44121,8 @@ namespace ts {
4412244121 }
4412344122 }
4412444123 }
44125-
44126- if (canHaveIllegalModifiers(prop) && prop.illegalModifiers) {
44127- for (const mod of prop.illegalModifiers) {
44128- grammarErrorOnNode(mod, Diagnostics._0_modifier_cannot_be_used_here, getTextOfNode(mod));
44129- }
44124+ else if (canHaveIllegalModifiers(prop) && prop.modifiers) {
44125+ grammarErrorOnNode(prop.modifiers[0], Diagnostics.Modifiers_cannot_appear_here);
4413044126 }
4413144127
4413244128 // ECMA-262 11.1.5 Object Initializer
@@ -44140,11 +44136,10 @@ namespace ts {
4414044136 let currentKind: DeclarationMeaning;
4414144137 switch (prop.kind) {
4414244138 case SyntaxKind.ShorthandPropertyAssignment:
44143- checkGrammarForInvalidExclamationToken(prop.illegalExclamationToken, Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context);
44144- // falls through
4414544139 case SyntaxKind.PropertyAssignment:
4414644140 // Grammar checking for computedPropertyName and shorthandPropertyAssignment
44147- checkGrammarForInvalidQuestionMark(prop.illegalQuestionToken, Diagnostics.An_object_member_cannot_be_declared_optional);
44141+ checkGrammarForInvalidExclamationToken(prop.exclamationToken, Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context);
44142+ checkGrammarForInvalidQuestionMark(prop.questionToken, Diagnostics.An_object_member_cannot_be_declared_optional);
4414844143 if (name.kind === SyntaxKind.NumericLiteral) {
4414944144 checkGrammarNumericLiteral(name);
4415044145 }
@@ -44376,7 +44371,7 @@ namespace ts {
4437644371 return grammarErrorOnNode(accessor.body, Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts);
4437744372 }
4437844373 }
44379- if (accessor.illegalTypeParameters ) {
44374+ if (accessor.typeParameters ) {
4438044375 return grammarErrorOnNode(accessor.name, Diagnostics.An_accessor_cannot_have_type_parameters);
4438144376 }
4438244377 if (!doesAccessorHaveCorrectParameterCount(accessor)) {
@@ -44386,7 +44381,7 @@ namespace ts {
4438644381 Diagnostics.A_set_accessor_must_have_exactly_one_parameter);
4438744382 }
4438844383 if (accessor.kind === SyntaxKind.SetAccessor) {
44389- if (accessor.illegalType ) {
44384+ if (accessor.type ) {
4439044385 return grammarErrorOnNode(accessor.name, Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation);
4439144386 }
4439244387 const parameter = Debug.checkDefined(getSetAccessorValueParameter(accessor), "Return value does not match parameter count assertion.");
@@ -44487,7 +44482,7 @@ namespace ts {
4448744482 else if (checkGrammarForInvalidQuestionMark(node.questionToken, Diagnostics.An_object_member_cannot_be_declared_optional)) {
4448844483 return true;
4448944484 }
44490- else if (checkGrammarForInvalidExclamationToken(node.illegalExclamationToken , Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context)) {
44485+ else if (checkGrammarForInvalidExclamationToken(node.exclamationToken , Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context)) {
4449144486 return true;
4449244487 }
4449344488 else if (node.body === undefined) {
@@ -44616,7 +44611,7 @@ namespace ts {
4461644611 }
4461744612
4461844613 function checkAmbientInitializer(node: VariableDeclaration | PropertyDeclaration | PropertySignature) {
44619- const initializer = hasOnlyExpressionInitializer( node) ? node .initializer : node.illegalInitializer ;
44614+ const initializer = node.initializer;
4462044615 if (initializer) {
4462144616 const isInvalidInitializer = !(
4462244617 isStringOrNumberLiteralExpression(initializer) ||
@@ -44813,15 +44808,15 @@ namespace ts {
4481344808
4481444809 function checkGrammarConstructorTypeParameters(node: ConstructorDeclaration) {
4481544810 const jsdocTypeParameters = isInJSFile(node) ? getJSDocTypeParameterDeclarations(node) : undefined;
44816- const range = node.illegalTypeParameters || jsdocTypeParameters && firstOrUndefined(jsdocTypeParameters);
44811+ const range = node.typeParameters || jsdocTypeParameters && firstOrUndefined(jsdocTypeParameters);
4481744812 if (range) {
4481844813 const pos = range.pos === range.end ? range.pos : skipTrivia(getSourceFileOfNode(node).text, range.pos);
4481944814 return grammarErrorAtPos(node, pos, range.end - pos, Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration);
4482044815 }
4482144816 }
4482244817
4482344818 function checkGrammarConstructorTypeAnnotation(node: ConstructorDeclaration) {
44824- const type = node.illegalType || getEffectiveReturnTypeNode(node);
44819+ const type = node.type || getEffectiveReturnTypeNode(node);
4482544820 if (type) {
4482644821 return grammarErrorOnNode(type, Diagnostics.Type_annotation_cannot_appear_on_a_constructor_declaration);
4482744822 }
@@ -44851,8 +44846,8 @@ namespace ts {
4485144846
4485244847 // Interfaces cannot contain property declarations
4485344848 Debug.assertNode(node, isPropertySignature);
44854- if (node.illegalInitializer ) {
44855- return grammarErrorOnNode(node.illegalInitializer , Diagnostics.An_interface_property_cannot_have_an_initializer);
44849+ if (node.initializer ) {
44850+ return grammarErrorOnNode(node.initializer , Diagnostics.An_interface_property_cannot_have_an_initializer);
4485644851 }
4485744852 }
4485844853 else if (isTypeLiteralNode(node.parent)) {
@@ -44861,8 +44856,8 @@ namespace ts {
4486144856 }
4486244857 // Type literals cannot contain property declarations
4486344858 Debug.assertNode(node, isPropertySignature);
44864- if (node.illegalInitializer ) {
44865- return grammarErrorOnNode(node.illegalInitializer , Diagnostics.A_type_literal_property_cannot_have_an_initializer);
44859+ if (node.initializer ) {
44860+ return grammarErrorOnNode(node.initializer , Diagnostics.A_type_literal_property_cannot_have_an_initializer);
4486644861 }
4486744862 }
4486844863
0 commit comments