@@ -201,12 +201,16 @@ export function getTemplates(options: ModuleOptions, uiConfig: Record<string, an
201201 // FIXME: `typeof colors[number]` should include all colors from the theme
202202 templates . push ( {
203203 filename : 'types/ui.d.ts' ,
204- getContents : ( ) => `import * as ui from '#build/ui'
204+ getContents : ( ) => {
205+ const iconKeys = Object . keys ( uiConfig ?. icons || { } )
206+ const iconUnion = iconKeys . length ? iconKeys . map ( i => JSON . stringify ( i ) ) . join ( ' | ' ) : 'string'
207+
208+ return `import * as ui from '#build/ui'
205209import type { TVConfig } from '@nuxt/ui'
206210import type { defaultConfig } from 'tailwind-variants'
207211import colors from 'tailwindcss/colors'
208212
209- const icons = ${ JSON . stringify ( uiConfig . icons ) } ;
213+ type IconsConfig = Record< ${ iconUnion } | (string & {}), string>
210214
211215type NeutralColor = 'slate' | 'gray' | 'zinc' | 'neutral' | 'stone'
212216type Color = Exclude<keyof typeof colors, 'inherit' | 'current' | 'transparent' | 'black' | 'white' | NeutralColor> | (string & {})
@@ -216,7 +220,7 @@ type AppConfigUI = {
216220 ${ options . theme ?. colors ?. map ( color => `'${ color } '?: Color` ) . join ( '\n\t\t' ) }
217221 neutral?: NeutralColor | (string & {})
218222 }
219- icons?: Partial<typeof icons >
223+ icons?: Partial<IconsConfig >
220224 tv?: typeof defaultConfig
221225} & TVConfig<typeof ui>
222226
@@ -232,6 +236,7 @@ declare module '@nuxt/schema' {
232236
233237export {}
234238`
239+ }
235240 } )
236241
237242 templates . push ( {
0 commit comments