Merge pull request #32893 from ajafff/classexpressionpropertymodifiers
report invalid modifiers on class expression properties
This commit is contained in:
commit
8f30c09d99
|
@ -32406,7 +32406,7 @@ namespace ts {
|
||||||
else if (flags & ModifierFlags.Async) {
|
else if (flags & ModifierFlags.Async) {
|
||||||
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "export", "async");
|
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "export", "async");
|
||||||
}
|
}
|
||||||
else if (node.parent.kind === SyntaxKind.ClassDeclaration) {
|
else if (isClassLike(node.parent)) {
|
||||||
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export");
|
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export");
|
||||||
}
|
}
|
||||||
else if (node.kind === SyntaxKind.Parameter) {
|
else if (node.kind === SyntaxKind.Parameter) {
|
||||||
|
@ -32429,7 +32429,7 @@ namespace ts {
|
||||||
else if (flags & ModifierFlags.Async) {
|
else if (flags & ModifierFlags.Async) {
|
||||||
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async");
|
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async");
|
||||||
}
|
}
|
||||||
else if (node.parent.kind === SyntaxKind.ClassDeclaration) {
|
else if (isClassLike(node.parent)) {
|
||||||
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare");
|
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare");
|
||||||
}
|
}
|
||||||
else if (node.kind === SyntaxKind.Parameter) {
|
else if (node.kind === SyntaxKind.Parameter) {
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
tests/cases/compiler/classExpressionPropertyModifiers.ts(2,5): error TS1031: 'declare' modifier cannot appear on a class element.
|
||||||
|
tests/cases/compiler/classExpressionPropertyModifiers.ts(3,5): error TS1031: 'export' modifier cannot appear on a class element.
|
||||||
|
|
||||||
|
|
||||||
|
==== tests/cases/compiler/classExpressionPropertyModifiers.ts (2 errors) ====
|
||||||
|
const a = class Cat {
|
||||||
|
declare [Symbol.toStringTag] = "uh";
|
||||||
|
~~~~~~~
|
||||||
|
!!! error TS1031: 'declare' modifier cannot appear on a class element.
|
||||||
|
export foo = 1;
|
||||||
|
~~~~~~
|
||||||
|
!!! error TS1031: 'export' modifier cannot appear on a class element.
|
||||||
|
}
|
||||||
|
|
8
tests/cases/compiler/classExpressionPropertyModifiers.ts
Normal file
8
tests/cases/compiler/classExpressionPropertyModifiers.ts
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
// @noEmit: true
|
||||||
|
// @noTypesAndSymbols: true
|
||||||
|
// @lib: es6
|
||||||
|
|
||||||
|
const a = class Cat {
|
||||||
|
declare [Symbol.toStringTag] = "uh";
|
||||||
|
export foo = 1;
|
||||||
|
}
|
Loading…
Reference in a new issue