0.1.0 (#1)
All checks were successful
continuous-integration/drone/push Build is passing

Co-authored-by: Julien Valverdé <julien.valverde@mailo.com>
Reviewed-on: https://git.jvalver.de/Thilawyn/traitify-ts/pulls/1
This commit was merged in pull request #1.
This commit is contained in:
Julien Valverdé
2024-02-06 03:15:39 +01:00
parent eaaabeec49
commit 65092c27cb
19 changed files with 582 additions and 423 deletions

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

@@ -0,0 +1,25 @@
import { Call, ComposeLeft, Fn, Match, Tuples } from "hotscript"
import { CommonKeys } from "."
type ExtendReducer<Super, Self> = (
Pick<Self, CommonKeys<Self, Super>> extends Pick<Super, CommonKeys<Self, Super>>
? Omit<Super, CommonKeys<Self, Super>> & Self
: never
)
interface ExtendReducerFn extends Fn {
return: ExtendReducer<this["arg0"], this["arg1"]>
}
export type ExtendFn = Tuples.Reduce<ExtendReducerFn, {}>
export type Extend<T extends {}[]> = Call<ExtendFn, T>
export type ExtendableFn = ComposeLeft<[
ExtendFn,
Match<[
Match.With<never, false>,
Match.With<any, true>,
]>
]>
export type Extendable<T extends {}[]> = Call<ExtendableFn, T>