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

This commit is contained in:
Julien Valverdé
2024-02-19 19:22:07 +01:00
parent b9dc68d97b
commit 9f36ce85be

View File

@@ -21,7 +21,11 @@ import { CommonKeys } from "."
export type Extend<T extends readonly object[]> = ( export type Extend<T extends readonly object[]> = (
T extends [infer Super, infer Self, ...infer Rest extends object[]] T extends [
infer Super,
infer Self,
...infer Rest extends 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<[
Omit<Super, CommonKeys<Self, Super>> & Self, Omit<Super, CommonKeys<Self, Super>> & Self,
@@ -34,12 +38,22 @@ export type Extend<T extends readonly object[]> = (
) )
export type Extendable<T extends readonly object[]> = ( export type Extendable<T extends readonly object[]> = (
T extends [infer Super, infer Self, ...infer Rest extends object[]] T extends [
infer Super extends object,
infer Self extends object,
...infer Rest extends 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<[
Omit<Super, CommonKeys<Self, Super>> & Self, Super & Self,
...Rest, ...Rest,
]> ]>
: false : false
: true : true
) )
export type NonExtendableKeys<T extends readonly object[]> = (
Extendable<T> extends false
? {}
: never
)