0.1.8 #9
@@ -1,4 +1,4 @@
|
|||||||
/**
|
/**
|
||||||
* Extracts the common keys between two types
|
* 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[]> = (
|
export type Extend<T extends readonly object[]> = (
|
||||||
@@ -7,9 +7,9 @@ export type Extend<T extends readonly object[]> = (
|
|||||||
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, CommonKeys2<Self, Super>> extends Pick<Super, CommonKeys2<Self, Super>>
|
||||||
? Extend<readonly [
|
? Extend<readonly [
|
||||||
Omit<Super, CommonKeys<Self, Super>> & Self,
|
Omit<Super, CommonKeys2<Self, Super>> & Self,
|
||||||
...Rest,
|
...Rest,
|
||||||
]>
|
]>
|
||||||
: never
|
: 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[]> = (
|
export type Override<T extends readonly object[]> = (
|
||||||
T extends readonly [
|
T extends readonly [
|
||||||
infer Super,
|
infer Super,
|
||||||
@@ -25,7 +28,7 @@ export type Override<T extends readonly object[]> = (
|
|||||||
...infer Rest extends readonly object[],
|
...infer Rest extends readonly object[],
|
||||||
]
|
]
|
||||||
? Override<readonly [
|
? Override<readonly [
|
||||||
Omit<Super, CommonKeys<Self, Super>> & Self,
|
Omit<Super, CommonKeys2<Self, Super>> & Self,
|
||||||
...Rest,
|
...Rest,
|
||||||
]>
|
]>
|
||||||
: T extends readonly [infer Self]
|
: T extends readonly [infer Self]
|
||||||
@@ -39,9 +42,9 @@ export type Extendable<T extends readonly object[]> = (
|
|||||||
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, CommonKeys2<Self, Super>> extends Pick<Super, CommonKeys2<Self, Super>>
|
||||||
? Extendable<readonly [
|
? Extendable<readonly [
|
||||||
Omit<Super, CommonKeys<Self, Super>> & Self,
|
Omit<Super, CommonKeys2<Self, Super>> & Self,
|
||||||
...Rest,
|
...Rest,
|
||||||
]>
|
]>
|
||||||
: false
|
: false
|
||||||
|
|||||||
Reference in New Issue
Block a user