feat(module): improve app config types autocomplete (#1870)

Co-authored-by: Dave Stewart <dev@davestewart.co.uk>
Co-authored-by: Benjamin Canac <canacb1@gmail.com>
This commit is contained in:
Dave Stewart
2024-07-09 11:23:57 +01:00
committed by GitHub
parent c0ef69d314
commit 3f8ea5dbde
3 changed files with 16 additions and 6 deletions

View File

@@ -1,15 +1,23 @@
export type Strategy = 'merge' | 'override'
export interface TightMap<O = any> {
[key: string]: TightMap | O
}
export type DeepPartial<T, O = any> = {
[P in keyof T]?: T[P] extends object
? DeepPartial<T[P], O>
: T[P];
} & {
[key: string]: O | TightMap<O>
}
export type NestedKeyOf<ObjectType extends Record<string, any>> = {
[Key in keyof ObjectType]: ObjectType[Key] extends Record<string, any>
? NestedKeyOf<ObjectType[Key]>
: Key
}[keyof ObjectType]
export type DeepPartial<T> = Partial<{
[P in keyof T]: DeepPartial<T[P]> | { [key: string]: string | object }
}>
type DeepKey<T, Keys extends string[]> =
Keys extends [infer First, ...infer Rest]
? First extends keyof T