mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
addressed PR feedback
This commit is contained in:
+14
-12
@@ -7053,24 +7053,26 @@ namespace ts {
|
||||
let nodeCheckFlag: NodeCheckFlags = 0;
|
||||
|
||||
if (!canUseSuperExpression) {
|
||||
if (isCallExpression) {
|
||||
// issue more specific error if super is used in computed property name
|
||||
// class A { foo() { return "1" }}
|
||||
// class B {
|
||||
// [super.foo()]() {}
|
||||
// }
|
||||
let current = node;
|
||||
while (current && current !== container && current.kind !== SyntaxKind.ComputedPropertyName) {
|
||||
current = current.parent;
|
||||
}
|
||||
if (current && current.kind === SyntaxKind.ComputedPropertyName) {
|
||||
error(node, Diagnostics.super_cannot_be_referenced_in_a_computed_property_name);
|
||||
}
|
||||
else if (isCallExpression) {
|
||||
error(node, Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors);
|
||||
}
|
||||
else if (!container || !container.parent || !(isClassLike(container.parent) || container.parent.kind === SyntaxKind.ObjectLiteralExpression)) {
|
||||
error(node, Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions);
|
||||
}
|
||||
else {
|
||||
// issue more specific error if super is used in computed property name
|
||||
let current = node;
|
||||
while (current && current !== container && current.kind !== SyntaxKind.ComputedPropertyName) {
|
||||
current = current.parent;
|
||||
}
|
||||
if (current && current.kind === SyntaxKind.ComputedPropertyName) {
|
||||
error(node, Diagnostics.super_cannot_be_referenced_in_a_computed_property_name);
|
||||
}
|
||||
else {
|
||||
error(node, Diagnostics.super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class);
|
||||
}
|
||||
error(node, Diagnostics.super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class);
|
||||
}
|
||||
return unknownType;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames24_ES5.ts(7,6): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames24_ES5.ts(7,6): error TS2466: 'super' cannot be referenced in a computed property name.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames24_ES5.ts (1 errors) ====
|
||||
@@ -10,5 +10,5 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames24_ES5.ts(7,
|
||||
class C extends Base {
|
||||
[super.bar()]() { }
|
||||
~~~~~
|
||||
!!! error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
|
||||
!!! error TS2466: 'super' cannot be referenced in a computed property name.
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames24_ES6.ts(9,6): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames24_ES6.ts(9,6): error TS2466: 'super' cannot be referenced in a computed property name.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames24_ES6.ts (1 errors) ====
|
||||
@@ -12,5 +12,5 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames24_ES6.ts(9,
|
||||
// use of super in static properties initializers.
|
||||
[super.bar()]() { }
|
||||
~~~~~
|
||||
!!! error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
|
||||
!!! error TS2466: 'super' cannot be referenced in a computed property name.
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames26_ES5.ts(8,12): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames26_ES5.ts(8,12): error TS2466: 'super' cannot be referenced in a computed property name.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames26_ES5.ts (1 errors) ====
|
||||
@@ -11,6 +11,6 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames26_ES5.ts(8,
|
||||
[
|
||||
{ [super.bar()]: 1 }[0]
|
||||
~~~~~
|
||||
!!! error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
|
||||
!!! error TS2466: 'super' cannot be referenced in a computed property name.
|
||||
]() { }
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames26_ES6.ts(10,12): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames26_ES6.ts(10,12): error TS2466: 'super' cannot be referenced in a computed property name.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames26_ES6.ts (1 errors) ====
|
||||
@@ -13,6 +13,6 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames26_ES6.ts(10
|
||||
[
|
||||
{ [super.bar()]: 1 }[0]
|
||||
~~~~~
|
||||
!!! error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
|
||||
!!! error TS2466: 'super' cannot be referenced in a computed property name.
|
||||
]() { }
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames27_ES5.ts(4,7): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames27_ES5.ts(4,7): error TS2466: 'super' cannot be referenced in a computed property name.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames27_ES5.ts (1 errors) ====
|
||||
@@ -7,5 +7,5 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames27_ES5.ts(4,
|
||||
class C extends Base {
|
||||
[(super(), "prop")]() { }
|
||||
~~~~~
|
||||
!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
|
||||
!!! error TS2466: 'super' cannot be referenced in a computed property name.
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames27_ES6.ts(4,7): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames27_ES6.ts(4,7): error TS2466: 'super' cannot be referenced in a computed property name.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames27_ES6.ts (1 errors) ====
|
||||
@@ -7,5 +7,5 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames27_ES6.ts(4,
|
||||
class C extends Base {
|
||||
[(super(), "prop")]() { }
|
||||
~~~~~
|
||||
!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
|
||||
!!! error TS2466: 'super' cannot be referenced in a computed property name.
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames30_ES5.ts(11,19): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames30_ES5.ts(11,19): error TS2466: 'super' cannot be referenced in a computed property name.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames30_ES5.ts (1 errors) ====
|
||||
@@ -14,7 +14,7 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames30_ES5.ts(11
|
||||
//treatment of other similar violations.
|
||||
[(super(), "prop")]() { }
|
||||
~~~~~
|
||||
!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
|
||||
!!! error TS2466: 'super' cannot be referenced in a computed property name.
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames30_ES6.ts(11,19): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames30_ES6.ts(11,19): error TS2466: 'super' cannot be referenced in a computed property name.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames30_ES6.ts (1 errors) ====
|
||||
@@ -14,7 +14,7 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames30_ES6.ts(11
|
||||
//treatment of other similar violations.
|
||||
[(super(), "prop")]() { }
|
||||
~~~~~
|
||||
!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
|
||||
!!! error TS2466: 'super' cannot be referenced in a computed property name.
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user