chore(templates): move DeepPartial to runtime types

chore(templates): up
This commit is contained in:
Benjamin Canac
2024-04-02 16:50:25 +02:00
parent ab9fc3eebb
commit f3c690ebd8
2 changed files with 20 additions and 21 deletions

3
src/runtime/types/utils.d.ts vendored Normal file
View File

@@ -0,0 +1,3 @@
export type DeepPartial<T> = Partial<{
[P in keyof T]: DeepPartial<T[P]> | { [key: string]: string | object }
}>

View File

@@ -70,30 +70,26 @@ export function addTemplates (options: ModuleOptions, nuxt: Nuxt) {
addTypeTemplate({
filename: 'types/ui.d.ts',
getContents: () => `import * as ui from '#build/ui'
import type { DeepPartial } from '#ui/types/utils'
type DeepPartial<T> = Partial<{
[P in keyof T]: DeepPartial<T[P]> | { [key: string]: string | object }
}>
const colors = ${JSON.stringify(options.colors)} as const;
const colors = ${JSON.stringify(options.colors)} as const;
type AppConfigUI = {
primary?: typeof colors[number]
gray?: 'slate' | 'cool' | 'zinc' | 'neutral' | 'stone'
} & DeepPartial<typeof ui>
type UI = {
primary?: typeof colors[number]
gray?: 'slate' | 'cool' | 'zinc' | 'neutral' | 'stone'
[key: string]: any
} & DeepPartial<typeof ui>
declare module 'nuxt/schema' {
interface AppConfigInput {
ui?: UI
}
}
declare module '@nuxt/schema' {
interface AppConfigInput {
ui?: UI
}
}
export {}
declare module 'nuxt/schema' {
interface AppConfigInput {
ui?: AppConfigUI
}
}
declare module '@nuxt/schema' {
interface AppConfigInput {
ui?: AppConfigUI
}
}
export {}
`
})
}