0.1.0 #1

Merged
Thilawyn merged 65 commits from next into master 2024-02-06 03:15:40 +01:00
3 changed files with 26 additions and 14 deletions
Showing only changes of commit e493331ff3 - Show all commits

View File

@@ -1,5 +1,5 @@
import { Simplify } from "type-fest"
import { Trait, TraitAbstractMembers, TraitImplInstance, expresses, trait } from "."
import { GetTraitAbstractMembers, GetTraitClass, GetTraitImplClass, GetTraitImplInstance, GetTraitInstance, Trait, TraitAbstractMembers, TraitImplInstance, expresses, trait } from "."
import { MergeInheritanceTree, TraitsAbstractMembers } from "./util"
import { Call, Fn, Tuples } from "hotscript"
@@ -41,13 +41,6 @@ const ActiveStatefulSubscription = trait<ActiveStatefulSubscriptionAbstractMembe
class ActiveStatefulSubscription extends Super {}
)
interface AbstractMembersOfTrait extends Fn {
return: this["arg0"] extends Trait<infer AbstractMembers, any>
? AbstractMembers
: never
}
// type Test = Simplify<TraitImplInstance<ReturnType<typeof Identifiable<bigint>>>>
type Test1 = [
TraitAbstractMembers<typeof StatefulSubscription>,
@@ -58,12 +51,10 @@ type Test2 = TraitsAbstractMembers<[
typeof ActiveStatefulSubscription,
]>
type Test3 = Simplify<
MergeInheritanceTree<
Call<Tuples.Map<AbstractMembersOfTrait>, [
Call<Tuples.Map<GetTraitClass>, [
typeof StatefulSubscription,
typeof ActiveStatefulSubscription,
]>
>
>
// type Test2 = Simplify<MergeInheritanceTree<Test1>>

View File

@@ -1,3 +1,4 @@
import { Fn } from "hotscript"
import { AbstractClass, Class, Opaque } from "type-fest"
import { StaticMembers } from "./util"
@@ -56,6 +57,10 @@ export type TraitAbstractMembers<T> = (
: never
)
export interface GetTraitAbstractMembers extends Fn {
return: TraitAbstractMembers<this["arg0"]>
}
export type TraitImplClass<T> = (
T extends Trait<infer AbstractMembers, infer ImplWithAbstractMembers>
? RemoveAbstractMembersFromImpl<
@@ -65,6 +70,10 @@ export type TraitImplClass<T> = (
: never
)
export interface GetTraitImplClass extends Fn {
return: TraitImplClass<this["arg0"]>
}
export type TraitImplInstance<T> = (
T extends Trait<infer AbstractMembers, infer ImplWithAbstractMembers>
? RemoveAbstractMembersFromImplInstance<
@@ -74,18 +83,30 @@ export type TraitImplInstance<T> = (
: never
)
export interface GetTraitImplInstance extends Fn {
return: TraitImplInstance<this["arg0"]>
}
export type TraitClass<T> = (
T extends Trait<any, infer ImplWithAbstractMembers>
? ImplWithAbstractMembers
: never
)
export interface GetTraitClass extends Fn {
return: TraitClass<this["arg0"]>
}
export type TraitInstance<T> = (
T extends Trait<any, infer ImplWithAbstractMembers>
? InstanceType<ImplWithAbstractMembers>
: never
)
export interface GetTraitInstance extends Fn {
return: TraitInstance<this["arg0"]>
}
export type TraitApplierSuperTag = "@thilawyn/traitify-ts/TraitApplierSuper"

0
src/util/extend.ts Normal file
View File