diff --git a/src/templates.ts b/src/templates.ts index c5e1036f96..31898d56a7 100644 --- a/src/templates.ts +++ b/src/templates.ts @@ -201,12 +201,16 @@ export function getTemplates(options: ModuleOptions, uiConfig: Record `import * as ui from '#build/ui' + getContents: () => { + const iconKeys = Object.keys(uiConfig?.icons || {}) + const iconUnion = iconKeys.length ? iconKeys.map(i => JSON.stringify(i)).join(' | ') : 'string' + + return `import * as ui from '#build/ui' import type { TVConfig } from '@nuxt/ui' import type { defaultConfig } from 'tailwind-variants' import colors from 'tailwindcss/colors' -const icons = ${JSON.stringify(uiConfig.icons)}; +type IconsConfig = Record<${iconUnion} | (string & {}), string> type NeutralColor = 'slate' | 'gray' | 'zinc' | 'neutral' | 'stone' type Color = Exclude | (string & {}) @@ -216,7 +220,7 @@ type AppConfigUI = { ${options.theme?.colors?.map(color => `'${color}'?: Color`).join('\n\t\t')} neutral?: NeutralColor | (string & {}) } - icons?: Partial + icons?: Partial tv?: typeof defaultConfig } & TVConfig @@ -232,6 +236,7 @@ declare module '@nuxt/schema' { export {} ` + } }) templates.push({