Skip to content

Commit 3a04406

Browse files
authored
fix: make the build output of the component regain its type (#389)
1 parent b94a067 commit 3a04406

File tree

6 files changed

+17
-14
lines changed

6 files changed

+17
-14
lines changed

src/runtime/components/css.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import { computed, watch, h, defineComponent } from 'vue'
33
import { getIconCSS } from '@iconify/utils/lib/css/icon'
44
import type { PropType } from 'vue'
55
import type { IconifyIcon } from '@iconify/types'
6-
import type { NuxtIconRuntimeOptions, NuxtIconRuntimeServerOptions, IconifyIconCustomizeCallback } from '../../types'
6+
import type { NuxtIconRuntimeOptions, NuxtIconRuntimeServerOptions } from '../../types'
7+
import type { IconifyIconCustomizeCallback } from './shared'
78
import { loadIcon, resolveCustomizeFn } from './shared'
89
import { useAppConfig, useNuxtApp, useHead, useRuntimeConfig, onServerPrefetch } from '#imports'
910

src/runtime/components/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { getIcon as _getIcon } from '@iconify/vue'
2-
import type { PropType, Component } from 'vue'
2+
import type { PropType } from 'vue'
33
import { computed, defineComponent, h } from 'vue'
4-
import type { NuxtIconRuntimeOptions, IconifyIconCustomizeCallback } from '../../types'
4+
import type { NuxtIconRuntimeOptions } from '../../types'
55
import { NuxtIconCss } from './css'
66
import { NuxtIconSvg } from './svg'
7+
import type { IconifyIconCustomizeCallback } from './shared'
78
import { useResolvedName } from './shared'
89
import { useAppConfig, useNuxtApp } from '#imports'
910

@@ -59,4 +60,4 @@ export default defineComponent({
5960
slots,
6061
)
6162
},
62-
}) as Component
63+
})

src/runtime/components/shared.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
import { computed } from 'vue'
22
import { getIcon as _getIcon, addIcon as _addIcon, loadIcon as _loadIcon } from '@iconify/vue'
33
import type { IconifyIcon } from '@iconify/types'
4-
import type { IconifyIconCustomizeCallback, NuxtIconRuntimeOptions } from '../../types'
4+
import type { NuxtIconRuntimeOptions } from '../../types'
55
import { useAppConfig } from '#imports'
66
import { init as initClientBundle } from '#build/nuxt-icon-client-bundle'
77

88
export { initClientBundle }
99

10+
export type IconifyIconCustomizeCallback = (
11+
content: string,
12+
name?: string,
13+
prefix?: string,
14+
provider?: string
15+
) => string
16+
1017
export async function loadIcon(name: string, timeout: number): Promise<Required<IconifyIcon> | null | undefined> {
1118
if (!name)
1219
return null

src/runtime/components/svg.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { Icon as Iconify, addIcon } from '@iconify/vue'
22
import { h } from 'vue'
33
import type { PropType } from 'vue'
4-
import type { NuxtIconRuntimeOptions, IconifyIconCustomizeCallback } from '../../types'
4+
import type { NuxtIconRuntimeOptions } from '../../types'
5+
import type { IconifyIconCustomizeCallback } from './shared'
56
import { initClientBundle, loadIcon, useResolvedName, resolveCustomizeFn } from './shared'
67
import { useAsyncData, useNuxtApp, defineComponent, useAppConfig, onServerPrefetch } from '#imports'
78

src/schema-types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// This file is generated from scripts/schema.ts
22

3-
import type { IconifyIconCustomizeCallback } from './types'
3+
import type { IconifyIconCustomizeCallback } from './runtime/components/shared'
44

55
export interface NuxtIconRuntimeOptions {
66
/**

src/types.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,6 @@ import type { NuxtIconRuntimeOptions } from './schema-types'
33

44
export type { NuxtIconRuntimeOptions }
55

6-
export type IconifyIconCustomizeCallback = (
7-
content: string,
8-
name?: string,
9-
prefix?: string,
10-
provider?: string
11-
) => string
12-
136
export interface NuxtIconRuntimeServerOptions {
147
/**
158
* List of pre-compiled CSS classnames to be used for server-side CSS icon rendering

0 commit comments

Comments
 (0)