From 3f8ea5dbded7b6836495103739688905ff26fe22 Mon Sep 17 00:00:00 2001 From: Dave Stewart Date: Tue, 9 Jul 2024 11:23:57 +0100 Subject: [PATCH] feat(module): improve app config types autocomplete (#1870) Co-authored-by: Dave Stewart Co-authored-by: Benjamin Canac --- docs/content/1.getting-started/3.theming.md | 4 +++- src/module.ts | 2 +- src/runtime/types/utils.d.ts | 16 ++++++++++++---- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/docs/content/1.getting-started/3.theming.md b/docs/content/1.getting-started/3.theming.md index 6b302a536e..3d3c7c6548 100644 --- a/docs/content/1.getting-started/3.theming.md +++ b/docs/content/1.getting-started/3.theming.md @@ -106,7 +106,7 @@ This can also happen when you bind a dynamic color to a component: ` +} & DeepPartial declare module 'nuxt/schema' { interface AppConfigInput { diff --git a/src/runtime/types/utils.d.ts b/src/runtime/types/utils.d.ts index 82a5488761..8b831507cf 100644 --- a/src/runtime/types/utils.d.ts +++ b/src/runtime/types/utils.d.ts @@ -1,15 +1,23 @@ export type Strategy = 'merge' | 'override' +export interface TightMap { + [key: string]: TightMap | O +} + +export type DeepPartial = { + [P in keyof T]?: T[P] extends object + ? DeepPartial + : T[P]; +} & { + [key: string]: O | TightMap +} + export type NestedKeyOf> = { [Key in keyof ObjectType]: ObjectType[Key] extends Record ? NestedKeyOf : Key }[keyof ObjectType] -export type DeepPartial = Partial<{ - [P in keyof T]: DeepPartial | { [key: string]: string | object } -}> - type DeepKey = Keys extends [infer First, ...infer Rest] ? First extends keyof T