Skip to content

Commit 01f9749

Browse files
committed
Revert 'illegalX' property renames
1 parent f3f2823 commit 01f9749

18 files changed

+263
-242
lines changed

Diff for: src/compiler/binder.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2792,7 +2792,7 @@ namespace ts {
27922792
}
27932793

27942794
function bindNamespaceExportDeclaration(node: NamespaceExportDeclaration) {
2795-
if (some(node.illegalModifiers)) {
2795+
if (some(node.modifiers)) {
27962796
file.bindDiagnostics.push(createDiagnosticForNode(node, Diagnostics.Modifiers_cannot_appear_here));
27972797
}
27982798
const diag = !isSourceFile(node.parent) ? Diagnostics.Global_module_exports_may_only_appear_at_top_level

Diff for: src/compiler/checker.ts

+25-28
Original file line numberDiff line numberDiff line change
@@ -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,9 +44121,8 @@ namespace ts {
4412244121
}
4412344122
}
4412444123
}
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) {
4412844126
grammarErrorOnNode(mod, Diagnostics._0_modifier_cannot_be_used_here, getTextOfNode(mod));
4412944127
}
4413044128
}
@@ -44140,11 +44138,10 @@ namespace ts {
4414044138
let currentKind: DeclarationMeaning;
4414144139
switch (prop.kind) {
4414244140
case SyntaxKind.ShorthandPropertyAssignment:
44143-
checkGrammarForInvalidExclamationToken(prop.illegalExclamationToken, Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context);
44144-
// falls through
4414544141
case SyntaxKind.PropertyAssignment:
4414644142
// 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);
4414844145
if (name.kind === SyntaxKind.NumericLiteral) {
4414944146
checkGrammarNumericLiteral(name);
4415044147
}
@@ -44376,7 +44373,7 @@ namespace ts {
4437644373
return grammarErrorOnNode(accessor.body, Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts);
4437744374
}
4437844375
}
44379-
if (accessor.illegalTypeParameters) {
44376+
if (accessor.typeParameters) {
4438044377
return grammarErrorOnNode(accessor.name, Diagnostics.An_accessor_cannot_have_type_parameters);
4438144378
}
4438244379
if (!doesAccessorHaveCorrectParameterCount(accessor)) {
@@ -44386,7 +44383,7 @@ namespace ts {
4438644383
Diagnostics.A_set_accessor_must_have_exactly_one_parameter);
4438744384
}
4438844385
if (accessor.kind === SyntaxKind.SetAccessor) {
44389-
if (accessor.illegalType) {
44386+
if (accessor.type) {
4439044387
return grammarErrorOnNode(accessor.name, Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation);
4439144388
}
4439244389
const parameter = Debug.checkDefined(getSetAccessorValueParameter(accessor), "Return value does not match parameter count assertion.");
@@ -44487,7 +44484,7 @@ namespace ts {
4448744484
else if (checkGrammarForInvalidQuestionMark(node.questionToken, Diagnostics.An_object_member_cannot_be_declared_optional)) {
4448844485
return true;
4448944486
}
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)) {
4449144488
return true;
4449244489
}
4449344490
else if (node.body === undefined) {
@@ -44616,7 +44613,7 @@ namespace ts {
4461644613
}
4461744614

4461844615
function checkAmbientInitializer(node: VariableDeclaration | PropertyDeclaration | PropertySignature) {
44619-
const initializer = hasOnlyExpressionInitializer(node) ? node.initializer : node.illegalInitializer;
44616+
const initializer = node.initializer;
4462044617
if (initializer) {
4462144618
const isInvalidInitializer = !(
4462244619
isStringOrNumberLiteralExpression(initializer) ||
@@ -44813,15 +44810,15 @@ namespace ts {
4481344810

4481444811
function checkGrammarConstructorTypeParameters(node: ConstructorDeclaration) {
4481544812
const jsdocTypeParameters = isInJSFile(node) ? getJSDocTypeParameterDeclarations(node) : undefined;
44816-
const range = node.illegalTypeParameters || jsdocTypeParameters && firstOrUndefined(jsdocTypeParameters);
44813+
const range = node.typeParameters || jsdocTypeParameters && firstOrUndefined(jsdocTypeParameters);
4481744814
if (range) {
4481844815
const pos = range.pos === range.end ? range.pos : skipTrivia(getSourceFileOfNode(node).text, range.pos);
4481944816
return grammarErrorAtPos(node, pos, range.end - pos, Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration);
4482044817
}
4482144818
}
4482244819

4482344820
function checkGrammarConstructorTypeAnnotation(node: ConstructorDeclaration) {
44824-
const type = node.illegalType || getEffectiveReturnTypeNode(node);
44821+
const type = node.type || getEffectiveReturnTypeNode(node);
4482544822
if (type) {
4482644823
return grammarErrorOnNode(type, Diagnostics.Type_annotation_cannot_appear_on_a_constructor_declaration);
4482744824
}
@@ -44851,8 +44848,8 @@ namespace ts {
4485144848

4485244849
// Interfaces cannot contain property declarations
4485344850
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);
4485644853
}
4485744854
}
4485844855
else if (isTypeLiteralNode(node.parent)) {
@@ -44861,8 +44858,8 @@ namespace ts {
4486144858
}
4486244859
// Type literals cannot contain property declarations
4486344860
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);
4486644863
}
4486744864
}
4486844865

Diff for: src/compiler/commandLineParser.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -2058,8 +2058,8 @@ namespace ts {
20582058
continue;
20592059
}
20602060

2061-
if (element.illegalQuestionToken) {
2062-
errors.push(createDiagnosticForNodeInSourceFile(sourceFile, element.illegalQuestionToken, Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, "?"));
2061+
if (element.questionToken) {
2062+
errors.push(createDiagnosticForNodeInSourceFile(sourceFile, element.questionToken, Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, "?"));
20632063
}
20642064
if (!isDoubleQuotedString(element.name)) {
20652065
errors.push(createDiagnosticForNodeInSourceFile(sourceFile, element.name, Diagnostics.String_literal_with_double_quotes_expected));

0 commit comments

Comments
 (0)