This commit is contained in:
@@ -29,19 +29,21 @@ type ExtendStaticAbstractSuper<SuperExpression, StaticAbstract> = (
|
|||||||
type TraitApplierSuperTag = "@thilawyn/traitify-ts/Super"
|
type TraitApplierSuperTag = "@thilawyn/traitify-ts/Super"
|
||||||
|
|
||||||
type RemoveAbstractFromImplClass<
|
type RemoveAbstractFromImplClass<
|
||||||
ImplClassWithAbstract extends (
|
ImplClassWithAbstract extends AbstractClass<object>,
|
||||||
Class<Abstract, []> &
|
Abstract extends AbstractClass<object>,
|
||||||
StaticAbstract &
|
|
||||||
{ _tag: TraitApplierSuperTag }
|
|
||||||
),
|
|
||||||
Abstract extends object,
|
|
||||||
StaticAbstract extends object,
|
|
||||||
> = (
|
> = (
|
||||||
Class<
|
Class<
|
||||||
Omit<InstanceType<ImplClassWithAbstract>, keyof Abstract>,
|
Omit<
|
||||||
|
InstanceType<ImplClassWithAbstract>,
|
||||||
|
keyof InstanceType<Abstract>
|
||||||
|
>,
|
||||||
|
|
||||||
ConstructorParameters<ImplClassWithAbstract>
|
ConstructorParameters<ImplClassWithAbstract>
|
||||||
> &
|
> &
|
||||||
Omit<StaticMembers<ImplClassWithAbstract>, keyof StaticAbstract | "_tag">
|
Omit<
|
||||||
|
StaticMembers<ImplClassWithAbstract>,
|
||||||
|
keyof StaticMembers<Abstract> | "_tag"
|
||||||
|
>
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -130,7 +132,12 @@ export class TraitBuilder<
|
|||||||
this.traitSuperExpression,
|
this.traitSuperExpression,
|
||||||
this.traitAbstract,
|
this.traitAbstract,
|
||||||
this.traitStaticAbstract,
|
this.traitStaticAbstract,
|
||||||
apply as unknown as (Super: AbstractClass<object>) => RemoveAbstractFromImplClass<ImplClassWithAbstract, Abstract, StaticAbstract>,
|
apply as unknown as (Super: AbstractClass<object>) => RemoveAbstractFromImplClass<
|
||||||
|
ImplClassWithAbstract,
|
||||||
|
TraitClass<
|
||||||
|
Trait<SuperExpression, Abstract, StaticAbstract, ImplClass>
|
||||||
|
>
|
||||||
|
>,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
17
src/tests.ts
17
src/tests.ts
@@ -87,3 +87,20 @@ class User extends exp.extends implements Implements<typeof exp> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
console.log(new User())
|
console.log(new User())
|
||||||
|
|
||||||
|
|
||||||
|
// class Test1 {
|
||||||
|
// prop1: string = "ouient"
|
||||||
|
// prop2: bigint = 1n
|
||||||
|
// }
|
||||||
|
|
||||||
|
// class Test2 extends Test1 {
|
||||||
|
// readonly prop1 = "juif"
|
||||||
|
// prop3: number = 69
|
||||||
|
// }
|
||||||
|
|
||||||
|
// type PureKeys<T, U> = {
|
||||||
|
// [K in keyof T]: K extends keyof U ? T[K] extends U[K] ? never : K : K;
|
||||||
|
// }[keyof T]
|
||||||
|
|
||||||
|
// type T = PureKeys<Test2, Test1>
|
||||||
|
|||||||
Reference in New Issue
Block a user