0.1.8 #9
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
* Extracts the common keys between two types
|
||||
*/
|
||||
export type CommonKeys<A, B> = Extract<keyof A, keyof B>
|
||||
export type CommonKeys2<A, B> = Extract<keyof A, keyof B>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { CommonKeys } from "./CommonKeys"
|
||||
import type { CommonKeys2 } from "./CommonKeys"
|
||||
|
||||
|
||||
export type Extend<T extends readonly object[]> = (
|
||||
@@ -7,9 +7,9 @@ export type Extend<T extends readonly object[]> = (
|
||||
infer Self,
|
||||
...infer Rest extends readonly object[],
|
||||
]
|
||||
? Pick<Self, CommonKeys<Self, Super>> extends Pick<Super, CommonKeys<Self, Super>>
|
||||
? Pick<Self, CommonKeys2<Self, Super>> extends Pick<Super, CommonKeys2<Self, Super>>
|
||||
? Extend<readonly [
|
||||
Omit<Super, CommonKeys<Self, Super>> & Self,
|
||||
Omit<Super, CommonKeys2<Self, Super>> & Self,
|
||||
...Rest,
|
||||
]>
|
||||
: never
|
||||
@@ -18,6 +18,9 @@ export type Extend<T extends readonly object[]> = (
|
||||
: {}
|
||||
)
|
||||
|
||||
export type Extend2<Self, Super> = Omit<Super, CommonKeys2<Self, Super>> & Self
|
||||
|
||||
|
||||
export type Override<T extends readonly object[]> = (
|
||||
T extends readonly [
|
||||
infer Super,
|
||||
@@ -25,7 +28,7 @@ export type Override<T extends readonly object[]> = (
|
||||
...infer Rest extends readonly object[],
|
||||
]
|
||||
? Override<readonly [
|
||||
Omit<Super, CommonKeys<Self, Super>> & Self,
|
||||
Omit<Super, CommonKeys2<Self, Super>> & Self,
|
||||
...Rest,
|
||||
]>
|
||||
: T extends readonly [infer Self]
|
||||
@@ -39,9 +42,9 @@ export type Extendable<T extends readonly object[]> = (
|
||||
infer Self,
|
||||
...infer Rest extends readonly object[],
|
||||
]
|
||||
? Pick<Self, CommonKeys<Self, Super>> extends Pick<Super, CommonKeys<Self, Super>>
|
||||
? Pick<Self, CommonKeys2<Self, Super>> extends Pick<Super, CommonKeys2<Self, Super>>
|
||||
? Extendable<readonly [
|
||||
Omit<Super, CommonKeys<Self, Super>> & Self,
|
||||
Omit<Super, CommonKeys2<Self, Super>> & Self,
|
||||
...Rest,
|
||||
]>
|
||||
: false
|
||||
|
||||
Reference in New Issue
Block a user