Skip to content

Commit 914d428

Browse files
committed
Add regression test
1 parent 049b336 commit 914d428

File tree

3 files changed

+82
-0
lines changed

3 files changed

+82
-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/baseExpressionTypeParameters.ts(10,27): error TS2561: Base class expressions cannot reference class type parameters.
2+
3+
4+
==== tests/cases/compiler/baseExpressionTypeParameters.ts (1 errors) ====
5+
// Repro from #17829
6+
7+
function base<T>() {
8+
class Base {
9+
static prop: T;
10+
}
11+
return Base;
12+
}
13+
14+
class Gen<T> extends base<T>() {} // Error, T not in scope
15+
~
16+
!!! error TS2561: Base class expressions cannot reference class type parameters.
17+
class Spec extends Gen<string> {}
18+
19+
<string>Spec.prop;
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
//// [baseExpressionTypeParameters.ts]
2+
// Repro from #17829
3+
4+
function base<T>() {
5+
class Base {
6+
static prop: T;
7+
}
8+
return Base;
9+
}
10+
11+
class Gen<T> extends base<T>() {} // Error, T not in scope
12+
class Spec extends Gen<string> {}
13+
14+
<string>Spec.prop;
15+
16+
//// [baseExpressionTypeParameters.js]
17+
// Repro from #17829
18+
var __extends = (this && this.__extends) || (function () {
19+
var extendStatics = Object.setPrototypeOf ||
20+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
21+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
22+
return function (d, b) {
23+
extendStatics(d, b);
24+
function __() { this.constructor = d; }
25+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
26+
};
27+
})();
28+
function base() {
29+
var Base = /** @class */ (function () {
30+
function Base() {
31+
}
32+
return Base;
33+
}());
34+
return Base;
35+
}
36+
var Gen = /** @class */ (function (_super) {
37+
__extends(Gen, _super);
38+
function Gen() {
39+
return _super !== null && _super.apply(this, arguments) || this;
40+
}
41+
return Gen;
42+
}(base())); // Error, T not in scope
43+
var Spec = /** @class */ (function (_super) {
44+
__extends(Spec, _super);
45+
function Spec() {
46+
return _super !== null && _super.apply(this, arguments) || this;
47+
}
48+
return Spec;
49+
}(Gen));
50+
Spec.prop;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Repro from #17829
2+
3+
function base<T>() {
4+
class Base {
5+
static prop: T;
6+
}
7+
return Base;
8+
}
9+
10+
class Gen<T> extends base<T>() {} // Error, T not in scope
11+
class Spec extends Gen<string> {}
12+
13+
<string>Spec.prop;

0 commit comments

Comments
 (0)