Extend fix
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Julien Valverdé
2024-02-25 02:41:42 +01:00
parent e72c1a59b0
commit a84f42ee91

View File

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