0.1.2 #3
16
src/tests.ts
16
src/tests.ts
@@ -59,20 +59,24 @@ class Box<T> {
|
||||
return "prout" as const
|
||||
}
|
||||
|
||||
method<
|
||||
C extends typeof Box & Class<I>,
|
||||
I extends Box<any>
|
||||
newBox<
|
||||
C extends Class<I, ConstructorParameters<typeof Box>>,
|
||||
I extends Box<any>,
|
||||
T,
|
||||
>(
|
||||
// this: Omit<BaseClass<T>, "constructor"> & { ["constructor"]: Class<I> }
|
||||
this: { ["constructor"]: C }
|
||||
this: { ["constructor"]: C | Class<I, ConstructorParameters<typeof Box>> },
|
||||
value: T,
|
||||
) {
|
||||
// this.otherMethod()
|
||||
return new this.constructor(69)
|
||||
return new this.constructor(value)
|
||||
}
|
||||
}
|
||||
|
||||
class UnrelatedClass {}
|
||||
|
||||
class SuperBox<T> extends Box<T> {
|
||||
declare ["constructor"]: typeof SuperBox
|
||||
}
|
||||
|
||||
console.log(new Superclass().method())
|
||||
const value = new SuperBox(69).newBox(69)
|
||||
|
||||
Reference in New Issue
Block a user