Skip to content

Commit a3cce38

Browse files
committed
addressed PR feedback
1 parent b65c577 commit a3cce38

5 files changed

Lines changed: 54 additions & 20 deletions

File tree

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7095,7 +7095,7 @@ namespace ts {
70957095

70967096
if (container.parent.kind === SyntaxKind.ObjectLiteralExpression) {
70977097
if (languageVersion < ScriptTarget.ES6) {
7098-
error(node, Diagnostics.super_in_members_of_object_literal_expressions_is_only_allowed_when_option_target_is_ES2015_or_higher);
7098+
error(node, Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher);
70997099
return unknownType;
71007100
}
71017101
else {

src/compiler/diagnosticMessages.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1759,7 +1759,7 @@
17591759
"category": "Error",
17601760
"code": 2658
17611761
},
1762-
"'super' in members of object literal expressions is only allowed when option 'target' is 'ES2015' or higher.": {
1762+
"'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher.": {
17631763
"category": "Error",
17641764
"code": 2659
17651765
},

tests/baselines/reference/superInObjectLiterals_ES5.errors.txt

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
tests/cases/compiler/superInObjectLiterals_ES5.ts(7,9): error TS2659: 'super' in members of object literal expressions is only allowed when option 'target' is 'ES2015' or higher.
2-
tests/cases/compiler/superInObjectLiterals_ES5.ts(10,9): error TS2659: 'super' in members of object literal expressions is only allowed when option 'target' is 'ES2015' or higher.
3-
tests/cases/compiler/superInObjectLiterals_ES5.ts(14,9): error TS2659: 'super' in members of object literal expressions is only allowed when option 'target' is 'ES2015' or higher.
1+
tests/cases/compiler/superInObjectLiterals_ES5.ts(7,9): error TS2659: 'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher.
2+
tests/cases/compiler/superInObjectLiterals_ES5.ts(10,9): error TS2659: 'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher.
3+
tests/cases/compiler/superInObjectLiterals_ES5.ts(14,9): error TS2659: 'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher.
44
tests/cases/compiler/superInObjectLiterals_ES5.ts(17,9): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
55
tests/cases/compiler/superInObjectLiterals_ES5.ts(20,9): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
66
tests/cases/compiler/superInObjectLiterals_ES5.ts(23,9): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
7-
tests/cases/compiler/superInObjectLiterals_ES5.ts(39,17): error TS2659: 'super' in members of object literal expressions is only allowed when option 'target' is 'ES2015' or higher.
8-
tests/cases/compiler/superInObjectLiterals_ES5.ts(42,17): error TS2659: 'super' in members of object literal expressions is only allowed when option 'target' is 'ES2015' or higher.
9-
tests/cases/compiler/superInObjectLiterals_ES5.ts(46,17): error TS2659: 'super' in members of object literal expressions is only allowed when option 'target' is 'ES2015' or higher.
7+
tests/cases/compiler/superInObjectLiterals_ES5.ts(39,17): error TS2659: 'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher.
8+
tests/cases/compiler/superInObjectLiterals_ES5.ts(42,17): error TS2659: 'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher.
9+
tests/cases/compiler/superInObjectLiterals_ES5.ts(46,17): error TS2659: 'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher.
1010
tests/cases/compiler/superInObjectLiterals_ES5.ts(49,17): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
1111
tests/cases/compiler/superInObjectLiterals_ES5.ts(52,17): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
1212

@@ -20,18 +20,18 @@ tests/cases/compiler/superInObjectLiterals_ES5.ts(52,17): error TS2660: 'super'
2020
method() {
2121
super.method();
2222
~~~~~
23-
!!! error TS2659: 'super' in members of object literal expressions is only allowed when option 'target' is 'ES2015' or higher.
23+
!!! error TS2659: 'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher.
2424
},
2525
get prop() {
2626
super.method();
2727
~~~~~
28-
!!! error TS2659: 'super' in members of object literal expressions is only allowed when option 'target' is 'ES2015' or higher.
28+
!!! error TS2659: 'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher.
2929
return 10;
3030
},
3131
set prop(value) {
3232
super.method();
3333
~~~~~
34-
!!! error TS2659: 'super' in members of object literal expressions is only allowed when option 'target' is 'ES2015' or higher.
34+
!!! error TS2659: 'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher.
3535
},
3636
p1: function () {
3737
super.method();
@@ -64,18 +64,18 @@ tests/cases/compiler/superInObjectLiterals_ES5.ts(52,17): error TS2660: 'super'
6464
method() {
6565
super.method();
6666
~~~~~
67-
!!! error TS2659: 'super' in members of object literal expressions is only allowed when option 'target' is 'ES2015' or higher.
67+
!!! error TS2659: 'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher.
6868
},
6969
get prop() {
7070
super.method();
7171
~~~~~
72-
!!! error TS2659: 'super' in members of object literal expressions is only allowed when option 'target' is 'ES2015' or higher.
72+
!!! error TS2659: 'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher.
7373
return 10;
7474
},
7575
set prop(value) {
7676
super.method();
7777
~~~~~
78-
!!! error TS2659: 'super' in members of object literal expressions is only allowed when option 'target' is 'ES2015' or higher.
78+
!!! error TS2659: 'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher.
7979
},
8080
p1: function () {
8181
super.method();

tests/baselines/reference/super_inside-object-literal-getters-and-setters.errors.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(4,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
2-
tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(5,20): error TS2659: 'super' in members of object literal expressions is only allowed when option 'target' is 'ES2015' or higher.
2+
tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(5,20): error TS2659: 'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher.
33
tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(7,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
4-
tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(8,13): error TS2659: 'super' in members of object literal expressions is only allowed when option 'target' is 'ES2015' or higher.
4+
tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(8,13): error TS2659: 'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher.
55
tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(11,20): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
66
tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(20,17): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
7-
tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(21,24): error TS2659: 'super' in members of object literal expressions is only allowed when option 'target' is 'ES2015' or higher.
7+
tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(21,24): error TS2659: 'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher.
88

99

1010
==== tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts (7 errors) ====
@@ -16,14 +16,14 @@ tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(21,24):
1616
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
1717
return super._foo;
1818
~~~~~
19-
!!! error TS2659: 'super' in members of object literal expressions is only allowed when option 'target' is 'ES2015' or higher.
19+
!!! error TS2659: 'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher.
2020
},
2121
set foo(value: string) {
2222
~~~
2323
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
2424
super._foo = value;
2525
~~~~~
26-
!!! error TS2659: 'super' in members of object literal expressions is only allowed when option 'target' is 'ES2015' or higher.
26+
!!! error TS2659: 'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher.
2727
},
2828
test: function () {
2929
return super._foo;
@@ -42,7 +42,7 @@ tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(21,24):
4242
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
4343
return super.test();
4444
~~~~~
45-
!!! error TS2659: 'super' in members of object literal expressions is only allowed when option 'target' is 'ES2015' or higher.
45+
!!! error TS2659: 'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher.
4646
}
4747
};
4848
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
////let x = {
4+
//// a() {
5+
//// return [|s/**/uper|].b();
6+
//// },
7+
//// b() {
8+
//// return [|super|].a();
9+
//// },
10+
//// c: function () {
11+
//// return [|super|].a();
12+
//// }
13+
//// d: () => [|super|].b();
14+
////}
15+
16+
function checkRange(r: FourSlashInterface.Range, expectedOccurences: FourSlashInterface.Range[]): void {
17+
goTo.position(r.start);
18+
if (expectedOccurences.length) {
19+
for (const expected of expectedOccurences) {
20+
verify.occurrencesAtPositionContains(expected);
21+
}
22+
}
23+
else {
24+
verify.occurrencesAtPositionCount(0);
25+
}
26+
}
27+
28+
let [r0, r1, r2, r3] = test.ranges();
29+
30+
checkRange(r0, [r0, r1]);
31+
checkRange(r1, [r0, r1]);
32+
checkRange(r0, [r0, r1]);
33+
checkRange(r2, []);
34+
checkRange(r3, []);

0 commit comments

Comments
 (0)