Skip to content

Commit 40796b2

Browse files
Added more tests.
1 parent 8ee09db commit 40796b2

18 files changed

+327
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
tests/cases/compiler/superCallFromClassThatDerivesFromGenericTypeButWithIncorrectNumberOfTypeArguments1.ts(8,17): error TS2314: Generic type 'A<T1, T2>' requires 2 type argument(s).
2+
tests/cases/compiler/superCallFromClassThatDerivesFromGenericTypeButWithIncorrectNumberOfTypeArguments1.ts(9,21): error TS2335: 'super' can only be referenced in a derived class.
3+
4+
5+
==== tests/cases/compiler/superCallFromClassThatDerivesFromGenericTypeButWithIncorrectNumberOfTypeArguments1.ts (2 errors) ====
6+
7+
class A<T1, T2> {
8+
constructor(private map: (value: T1) => T2) {
9+
10+
}
11+
}
12+
13+
class B extends A<number> {
14+
~~~~~~~~~
15+
!!! error TS2314: Generic type 'A<T1, T2>' requires 2 type argument(s).
16+
constructor() { super(value => String(value)); }
17+
~~~~~
18+
!!! error TS2335: 'super' can only be referenced in a derived class.
19+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//// [superCallFromClassThatDerivesFromGenericTypeButWithIncorrectNumberOfTypeArguments1.ts]
2+
3+
class A<T1, T2> {
4+
constructor(private map: (value: T1) => T2) {
5+
6+
}
7+
}
8+
9+
class B extends A<number> {
10+
constructor() { super(value => String(value)); }
11+
}
12+
13+
//// [superCallFromClassThatDerivesFromGenericTypeButWithIncorrectNumberOfTypeArguments1.js]
14+
var __extends = this.__extends || function (d, b) {
15+
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
16+
function __() { this.constructor = d; }
17+
__.prototype = b.prototype;
18+
d.prototype = new __();
19+
};
20+
var A = (function () {
21+
function A(map) {
22+
this.map = map;
23+
}
24+
return A;
25+
})();
26+
var B = (function (_super) {
27+
__extends(B, _super);
28+
function B() {
29+
_super.call(this, function (value) { return String(value); });
30+
}
31+
return B;
32+
})(A);
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
tests/cases/compiler/superCallFromClassThatDerivesFromGenericTypeButWithNoTypeArguments1.ts(8,17): error TS2314: Generic type 'A<T1, T2>' requires 2 type argument(s).
2+
tests/cases/compiler/superCallFromClassThatDerivesFromGenericTypeButWithNoTypeArguments1.ts(9,21): error TS2335: 'super' can only be referenced in a derived class.
3+
4+
5+
==== tests/cases/compiler/superCallFromClassThatDerivesFromGenericTypeButWithNoTypeArguments1.ts (2 errors) ====
6+
7+
class A<T1, T2> {
8+
constructor(private map: (value: T1) => T2) {
9+
10+
}
11+
}
12+
13+
class B extends A {
14+
~
15+
!!! error TS2314: Generic type 'A<T1, T2>' requires 2 type argument(s).
16+
constructor() { super(value => String(value)); }
17+
~~~~~
18+
!!! error TS2335: 'super' can only be referenced in a derived class.
19+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//// [superCallFromClassThatDerivesFromGenericTypeButWithNoTypeArguments1.ts]
2+
3+
class A<T1, T2> {
4+
constructor(private map: (value: T1) => T2) {
5+
6+
}
7+
}
8+
9+
class B extends A {
10+
constructor() { super(value => String(value)); }
11+
}
12+
13+
//// [superCallFromClassThatDerivesFromGenericTypeButWithNoTypeArguments1.js]
14+
var __extends = this.__extends || function (d, b) {
15+
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
16+
function __() { this.constructor = d; }
17+
__.prototype = b.prototype;
18+
d.prototype = new __();
19+
};
20+
var A = (function () {
21+
function A(map) {
22+
this.map = map;
23+
}
24+
return A;
25+
})();
26+
var B = (function (_super) {
27+
__extends(B, _super);
28+
function B() {
29+
_super.call(this, function (value) { return String(value); });
30+
}
31+
return B;
32+
})(A);
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
tests/cases/compiler/superCallFromClassThatDerivesNonGenericTypeButWithTypeArguments1.ts(8,17): error TS2315: Type 'A' is not generic.
2+
tests/cases/compiler/superCallFromClassThatDerivesNonGenericTypeButWithTypeArguments1.ts(9,21): error TS2335: 'super' can only be referenced in a derived class.
3+
4+
5+
==== tests/cases/compiler/superCallFromClassThatDerivesNonGenericTypeButWithTypeArguments1.ts (2 errors) ====
6+
7+
class A {
8+
constructor(private map: (value: number) => string) {
9+
10+
}
11+
}
12+
13+
class B extends A<number, string> {
14+
~~~~~~~~~~~~~~~~~
15+
!!! error TS2315: Type 'A' is not generic.
16+
constructor() { super(value => String(value)); }
17+
~~~~~
18+
!!! error TS2335: 'super' can only be referenced in a derived class.
19+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//// [superCallFromClassThatDerivesNonGenericTypeButWithTypeArguments1.ts]
2+
3+
class A {
4+
constructor(private map: (value: number) => string) {
5+
6+
}
7+
}
8+
9+
class B extends A<number, string> {
10+
constructor() { super(value => String(value)); }
11+
}
12+
13+
//// [superCallFromClassThatDerivesNonGenericTypeButWithTypeArguments1.js]
14+
var __extends = this.__extends || function (d, b) {
15+
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
16+
function __() { this.constructor = d; }
17+
__.prototype = b.prototype;
18+
d.prototype = new __();
19+
};
20+
var A = (function () {
21+
function A(map) {
22+
this.map = map;
23+
}
24+
return A;
25+
})();
26+
var B = (function (_super) {
27+
__extends(B, _super);
28+
function B() {
29+
_super.call(this, function (value) { return String(value); });
30+
}
31+
return B;
32+
})(A);
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
tests/cases/compiler/superCallFromClassThatHasNoBaseType1.ts(9,21): error TS2335: 'super' can only be referenced in a derived class.
2+
3+
4+
==== tests/cases/compiler/superCallFromClassThatHasNoBaseType1.ts (1 errors) ====
5+
6+
class A {
7+
constructor(private map: (value: number) => string) {
8+
9+
}
10+
}
11+
12+
class B {
13+
constructor() { super(value => String(value)); }
14+
~~~~~
15+
!!! error TS2335: 'super' can only be referenced in a derived class.
16+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//// [superCallFromClassThatHasNoBaseType1.ts]
2+
3+
class A {
4+
constructor(private map: (value: number) => string) {
5+
6+
}
7+
}
8+
9+
class B {
10+
constructor() { super(value => String(value)); }
11+
}
12+
13+
//// [superCallFromClassThatHasNoBaseType1.js]
14+
var A = (function () {
15+
function A(map) {
16+
this.map = map;
17+
}
18+
return A;
19+
})();
20+
var B = (function () {
21+
function B() {
22+
_super.call(this, function (value) { return String(value); });
23+
}
24+
return B;
25+
})();
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
tests/cases/compiler/superCallFromFunction1.ts(3,5): error TS2335: 'super' can only be referenced in a derived class.
2+
3+
4+
==== tests/cases/compiler/superCallFromFunction1.ts (1 errors) ====
5+
6+
function foo() {
7+
super(value => String(value));
8+
~~~~~
9+
!!! error TS2335: 'super' can only be referenced in a derived class.
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//// [superCallFromFunction1.ts]
2+
3+
function foo() {
4+
super(value => String(value));
5+
}
6+
7+
//// [superCallFromFunction1.js]
8+
function foo() {
9+
_super.call(this, function (value) { return String(value); });
10+
}

0 commit comments

Comments
 (0)