0.1.12 #12
@@ -22,30 +22,30 @@ import { CommonKeys } from "."
|
|||||||
|
|
||||||
// TODO: use OverrideProperties from type-fest?
|
// TODO: use OverrideProperties from type-fest?
|
||||||
export type Extend<T extends readonly object[]> = (
|
export type Extend<T extends readonly object[]> = (
|
||||||
T extends [
|
T extends readonly [
|
||||||
infer Super,
|
infer Super,
|
||||||
infer Self,
|
infer Self,
|
||||||
...infer Rest extends readonly object[],
|
...infer Rest extends readonly object[],
|
||||||
]
|
]
|
||||||
? Pick<Self, CommonKeys<Self, Super>> extends Pick<Super, CommonKeys<Self, Super>>
|
? Pick<Self, CommonKeys<Self, Super>> extends Pick<Super, CommonKeys<Self, Super>>
|
||||||
? Extend<[
|
? Extend<readonly [
|
||||||
Omit<Super, CommonKeys<Self, Super>> & Self,
|
Omit<Super, CommonKeys<Self, Super>> & Self,
|
||||||
...Rest,
|
...Rest,
|
||||||
]>
|
]>
|
||||||
: never
|
: never
|
||||||
: T extends [infer Self]
|
: T extends readonly [infer Self]
|
||||||
? Self
|
? Self
|
||||||
: {}
|
: {}
|
||||||
)
|
)
|
||||||
|
|
||||||
export type Extendable<T extends readonly object[]> = (
|
export type Extendable<T extends readonly object[]> = (
|
||||||
T extends [
|
T extends readonly [
|
||||||
infer Super,
|
infer Super,
|
||||||
infer Self,
|
infer Self,
|
||||||
...infer Rest extends readonly object[],
|
...infer Rest extends readonly object[],
|
||||||
]
|
]
|
||||||
? Pick<Self, CommonKeys<Self, Super>> extends Pick<Super, CommonKeys<Self, Super>>
|
? Pick<Self, CommonKeys<Self, Super>> extends Pick<Super, CommonKeys<Self, Super>>
|
||||||
? Extendable<[
|
? Extendable<readonly [
|
||||||
Omit<Super, CommonKeys<Self, Super>> & Self,
|
Omit<Super, CommonKeys<Self, Super>> & Self,
|
||||||
...Rest,
|
...Rest,
|
||||||
]>
|
]>
|
||||||
@@ -54,7 +54,7 @@ export type Extendable<T extends readonly object[]> = (
|
|||||||
)
|
)
|
||||||
|
|
||||||
export type NonExtendableKeys<T extends readonly object[]> = (
|
export type NonExtendableKeys<T extends readonly object[]> = (
|
||||||
T extends [
|
T extends readonly [
|
||||||
infer Super extends object,
|
infer Super extends object,
|
||||||
infer Self extends object,
|
infer Self extends object,
|
||||||
...infer Rest extends readonly object[],
|
...infer Rest extends readonly object[],
|
||||||
@@ -63,7 +63,7 @@ export type NonExtendableKeys<T extends readonly object[]> = (
|
|||||||
? never
|
? never
|
||||||
: K
|
: K
|
||||||
}[keyof Super & keyof Self]
|
}[keyof Super & keyof Self]
|
||||||
| NonExtendableKeys<[
|
| NonExtendableKeys<readonly [
|
||||||
Super & Self,
|
Super & Self,
|
||||||
...Rest,
|
...Rest,
|
||||||
]>
|
]>
|
||||||
|
|||||||
Reference in New Issue
Block a user