Test assignability of inherited generic default constructor
This commit is contained in:
parent
c62b6cb6fc
commit
c172c06777
4 changed files with 126 additions and 0 deletions
|
@ -0,0 +1,37 @@
|
|||
//// [genericInheritedImplicitConstructors.ts]
|
||||
interface Constructor<T> {
|
||||
new(...args: any[]): T;
|
||||
prototype: T;
|
||||
}
|
||||
|
||||
class A<U> { a: U; }
|
||||
class B<V> extends A<V> { b: V; }
|
||||
var c:Constructor<B<boolean>> = B; // error here
|
||||
|
||||
//class A1 { a: boolean; }
|
||||
//class B1 extends A1 { b: boolean; }
|
||||
//var c1:Constructor<B1> = B1; // no error here
|
||||
|
||||
|
||||
//// [genericInheritedImplicitConstructors.js]
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
var A = (function () {
|
||||
function A() {
|
||||
}
|
||||
return A;
|
||||
}());
|
||||
var B = (function (_super) {
|
||||
__extends(B, _super);
|
||||
function B() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
return B;
|
||||
}(A));
|
||||
var c = B; // error here
|
||||
//class A1 { a: boolean; }
|
||||
//class B1 extends A1 { b: boolean; }
|
||||
//var c1:Constructor<B1> = B1; // no error here
|
|
@ -0,0 +1,38 @@
|
|||
=== tests/cases/compiler/genericInheritedImplicitConstructors.ts ===
|
||||
interface Constructor<T> {
|
||||
>Constructor : Symbol(Constructor, Decl(genericInheritedImplicitConstructors.ts, 0, 0))
|
||||
>T : Symbol(T, Decl(genericInheritedImplicitConstructors.ts, 0, 22))
|
||||
|
||||
new(...args: any[]): T;
|
||||
>args : Symbol(args, Decl(genericInheritedImplicitConstructors.ts, 1, 8))
|
||||
>T : Symbol(T, Decl(genericInheritedImplicitConstructors.ts, 0, 22))
|
||||
|
||||
prototype: T;
|
||||
>prototype : Symbol(Constructor.prototype, Decl(genericInheritedImplicitConstructors.ts, 1, 27))
|
||||
>T : Symbol(T, Decl(genericInheritedImplicitConstructors.ts, 0, 22))
|
||||
}
|
||||
|
||||
class A<U> { a: U; }
|
||||
>A : Symbol(A, Decl(genericInheritedImplicitConstructors.ts, 3, 1))
|
||||
>U : Symbol(U, Decl(genericInheritedImplicitConstructors.ts, 5, 8))
|
||||
>a : Symbol(A.a, Decl(genericInheritedImplicitConstructors.ts, 5, 12))
|
||||
>U : Symbol(U, Decl(genericInheritedImplicitConstructors.ts, 5, 8))
|
||||
|
||||
class B<V> extends A<V> { b: V; }
|
||||
>B : Symbol(B, Decl(genericInheritedImplicitConstructors.ts, 5, 20))
|
||||
>V : Symbol(V, Decl(genericInheritedImplicitConstructors.ts, 6, 8))
|
||||
>A : Symbol(A, Decl(genericInheritedImplicitConstructors.ts, 3, 1))
|
||||
>V : Symbol(V, Decl(genericInheritedImplicitConstructors.ts, 6, 8))
|
||||
>b : Symbol(B.b, Decl(genericInheritedImplicitConstructors.ts, 6, 25))
|
||||
>V : Symbol(V, Decl(genericInheritedImplicitConstructors.ts, 6, 8))
|
||||
|
||||
var c:Constructor<B<boolean>> = B; // error here
|
||||
>c : Symbol(c, Decl(genericInheritedImplicitConstructors.ts, 7, 3))
|
||||
>Constructor : Symbol(Constructor, Decl(genericInheritedImplicitConstructors.ts, 0, 0))
|
||||
>B : Symbol(B, Decl(genericInheritedImplicitConstructors.ts, 5, 20))
|
||||
>B : Symbol(B, Decl(genericInheritedImplicitConstructors.ts, 5, 20))
|
||||
|
||||
//class A1 { a: boolean; }
|
||||
//class B1 extends A1 { b: boolean; }
|
||||
//var c1:Constructor<B1> = B1; // no error here
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
=== tests/cases/compiler/genericInheritedImplicitConstructors.ts ===
|
||||
interface Constructor<T> {
|
||||
>Constructor : Constructor<T>
|
||||
>T : T
|
||||
|
||||
new(...args: any[]): T;
|
||||
>args : any[]
|
||||
>T : T
|
||||
|
||||
prototype: T;
|
||||
>prototype : T
|
||||
>T : T
|
||||
}
|
||||
|
||||
class A<U> { a: U; }
|
||||
>A : A<U>
|
||||
>U : U
|
||||
>a : U
|
||||
>U : U
|
||||
|
||||
class B<V> extends A<V> { b: V; }
|
||||
>B : B<V>
|
||||
>V : V
|
||||
>A : A<V>
|
||||
>V : V
|
||||
>b : V
|
||||
>V : V
|
||||
|
||||
var c:Constructor<B<boolean>> = B; // error here
|
||||
>c : Constructor<B<boolean>>
|
||||
>Constructor : Constructor<T>
|
||||
>B : B<V>
|
||||
>B : typeof B
|
||||
|
||||
//class A1 { a: boolean; }
|
||||
//class B1 extends A1 { b: boolean; }
|
||||
//var c1:Constructor<B1> = B1; // no error here
|
||||
|
13
tests/cases/compiler/genericInheritedDefaultConstructors.ts
Normal file
13
tests/cases/compiler/genericInheritedDefaultConstructors.ts
Normal file
|
@ -0,0 +1,13 @@
|
|||
interface Constructor<T> {
|
||||
new(...args: any[]): T;
|
||||
prototype: T;
|
||||
}
|
||||
|
||||
class A<U> { a: U; }
|
||||
class B<V> extends A<V> { b: V; }
|
||||
var c:Constructor<B<boolean>> = B; // error here
|
||||
var x = new B<number>();
|
||||
|
||||
//class A1 { a: boolean; }
|
||||
//class B1 extends A1 { b: boolean; }
|
||||
//var c1:Constructor<B1> = B1; // no error here
|
Loading…
Reference in a new issue