Skip to content

Instantly share code, notes, and snippets.

@Diullei
Last active April 11, 2017 16:45
Show Gist options
  • Save Diullei/21ad4fe56cd51e9330c998995d17a23e to your computer and use it in GitHub Desktop.
Save Diullei/21ad4fe56cd51e9330c998995d17a23e to your computer and use it in GitHub Desktop.
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