This commit is contained in:
@@ -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>,
|
||||
// ]>
|
||||
// ]>
|
||||
|
||||
Reference in New Issue
Block a user