Last active
April 11, 2017 16:45
-
-
Save Diullei/21ad4fe56cd51e9330c998995d17a23e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abstract class AbstractInternal<T> { | |
public abstract method(arg: T): void; | |
} | |
type InternalCtor<T> = new (param: T) => AbstractInternal<T>; | |
function createClass<T>(data: T): InternalCtor<T> { | |
abstract class Internal<T> implements AbstractInternal<T> | |
{ | |
public constructor(arg: T) { | |
console.log(data, arg); | |
} | |
public abstract method(arg: T): void; | |
} | |
return Internal as InternalCtor<T>; | |
} | |
class A extends createClass<number>(1) { | |
public method(arg: number) { // now I need to implement this to avoid a compilation error | |
console.log('hello'); | |
} | |
} | |
const z = new A(2); // 1 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment