ExtendPlain -> Extend
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Julien Valverdé
2024-02-19 17:50:34 +01:00
parent 49f0f7b987
commit 8de5750d2e
5 changed files with 38 additions and 42 deletions

View File

@@ -1,25 +1,22 @@
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 readonly object[]> = Call<ExtendFn, T>
// 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 ExtendPlain<T extends readonly object[]> = (
export type Extend<T extends readonly object[]> = (
T extends [infer Super, infer Self, ...infer Rest]
? Rest extends object[]
? Pick<Self, CommonKeys<Self, Super>> extends Pick<Super, CommonKeys<Self, Super>>
? ExtendPlain<[
? Extend<[
Omit<Super, CommonKeys<Self, Super>> & Self,
...Rest,
]>
@@ -33,11 +30,10 @@ export type ExtendPlain<T extends readonly object[]> = (
)
export type ExtendableFn = ComposeLeft<[
ExtendFn,
Match<[
Match.With<never, false>,
Match.With<any, true>,
]>
]>
export type Extendable<T extends object[]> = Call<ExtendableFn, T>
// export type ExtendableFn = ComposeLeft<[
// ExtendFn,
// Match<[
// Match.With<never, false>,
// Match.With<any, true>,
// ]>
// ]>