Repository navigation
Description
Describe the bug
During a distribution build (nuxt-module-build / @nuxt/module-builder), generated .d.vue.ts files are not consistent.
A small <script setup lang="ts"> SFC is emitted as any. A generic SFC built in the same run keeps its generic parameter and its props. Consumers of the published package then see the simple component as any: no props autocomplete, no excess-property check.
There is no public reduced repository. The two SFCs below are the inputs, and the two .d.vue.ts blocks are the outputs of that build. Both templates use $t and Nuxt UI components, so an unresolved template global is not enough to explain why one file collapses and the other does not.
Failing SFC
<script setup lang="ts">
type Props = {
description?: string;
};
defineProps<Props>();
</script>
<template>
<div class="text-dimmed flex flex-col items-center justify-center gap-2 p-4">
<UIcon name="lucide:circle-alert" class="size-5" />
<span class="text-sm font-medium">
{{ description ?? $t("global.anErrorOccurred") }}
</span>
</div>
</template>Generated .d.vue.ts:
declare const __VLS_export: any;
declare const _default: typeof __VLS_export;
export default _default;description is gone. The file is only the any fallback.
Working SFC
Same build. This component is generic, assigns defineProps, and has value imports.
<script
setup
lang="ts"
generic="
R extends
| { id?: number | string; disabled?: boolean; [key: string]: any }
| TableRow<{ id?: number | string; disabled?: boolean; [key: string]: any }>
"
>
import type { TableRow } from "@nuxt/ui";
import { computed, ref } from "#imports";
import { applyLoadingState, wrapRowActions, type AdminTableRowAction } from "./rowActions";
type Props = {
row: R;
rowActions: (row: R) => AdminTableRowAction[] | AdminTableRowAction[][];
};
const props = defineProps<Props>();
const open = ref(false);
const loadingActionKey = ref<string | null>(null);
function disabledTooltipAttr(item: AdminTableRowAction) {
if (item.disabledReason === "custom") {
return {
icon: item.disabledTooltip?.icon,
title: item.disabledTooltip?.title,
description: item.disabledTooltip?.description,
};
}
return null;
}
const wrappedItems = computed(() => {
return wrapRowActions(props.rowActions(props.row) ?? [], {
rowId: props.row?.id ?? "",
onAsyncStart: (actionKey) => {
loadingActionKey.value = actionKey;
open.value = true;
},
onAsyncEnd: (actionKey) => {
if (loadingActionKey.value === actionKey) {
loadingActionKey.value = null;
}
open.value = false;
},
});
});
const items = computed(() => applyLoadingState(wrappedItems.value, loadingActionKey.value));
</script>
<template>
<UDropdownMenu
v-model:open="open"
:items
:content="{ align: 'end' }"
:ui="{ item: 'py-0 items-center' }"
>
<UButton
icon="lucide:ellipsis-vertical"
color="neutral"
variant="outline"
:aria-label="$t('global.action', 2)"
/>
<template #item="{ item }">
<!-- On n'affiche pas le tooltip si l'item est actif ou que son type est custom (par défaut) mais sans paramétrage -->
<CommonTooltip
:disabled="
!item.disabled ||
((!item.disabledReason || item.disabledReason === 'custom') && !disabledTooltipAttr(item))
"
:variant="item.disabledReason"
position="left"
v-bind="disabledTooltipAttr(item)"
>
<div class="flex w-full items-center gap-2">
<!-- Le slot #item remplace le rendu Nuxt UI : il faut gérer le loading ici -->
<UIcon
v-if="item.loading"
name="lucide:loader-circle"
class="text-dimmed size-5 shrink-0 animate-spin"
/>
<UIcon
v-else-if="item.icon"
:name="item.icon"
class="text-dimmed group-data-highlighted:text-default group-data-[state=open]:text-default size-5 shrink-0 transition-colors"
:class="{ 'text-muted': item.disabled }"
/>
<span class="w-full py-1.5 text-left">{{ item.label }}</span>
<UIcon
v-if="item.children?.length"
name="lucide:chevron-right"
class="text-dimmed size-4 shrink-0"
/>
</div>
</CommonTooltip>
</template>
</UDropdownMenu>
</template>Generated .d.vue.ts:
import type { TableRow } from "@nuxt/ui";
import { type AdminTableRowAction } from "./rowActions.js";
declare const __VLS_export: <R extends {
id?: number | string;
disabled?: boolean;
[key: string]: any;
} | TableRow<{
id?: number | string;
disabled?: boolean;
[key: string]: any;
}>>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
props: import("vue").PublicProps & __VLS_PrettifyLocal<{
row: R;
rowActions: (row: R) => AdminTableRowAction[] | AdminTableRowAction[][];
}> & (typeof globalThis extends {
__VLS_PROPS_FALLBACK: infer P;
} ? P : {});
expose: (exposed: {}) => void;
attrs: any;
slots: {};
emit: {};
}>) => import("vue").VNode & {
__ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
};
declare const _default: typeof __VLS_export;
export default _default;
type __VLS_PrettifyLocal<T> = (T extends any ? {
[K in keyof T]: T[K];
} : {
[K in keyof T as K]: T[K];
}) & {};row and rowActions are preserved, including the generic R.
Expected
The simple SFC should emit a .d.vue.ts whose props include description?: string, the same way the generic SFC exposes row and rowActions.
What is different in the failing script
- no import at all (after macro compilation the script is only a type alias and a
defineProps()call) defineProps<Props>()is not assigned- no
genericattribute
The working script has value imports, assigns const props = defineProps<Props>(), and declares a generic.
Both templates reference $t and auto-imported components (UIcon, and also UButton / UDropdownMenu / CommonTooltip on the working one). The working declaration still carries the prop types, so a template global missing from the declaration program does not, by itself, force __VLS_export: any.
The any file is the whole export. It does not contain __VLS_Props, description, or a diagnostic saying generation failed.
Additional context
Existing module-builder issues around component types (#379, #597, #701, #786) do not describe this split: one SFC emitted as declare const __VLS_export: any, another from the same build emitted with its props.
@nuxt/module-builder and vue-tsc versions were not recorded with this report. The working declaration uses the current vue-tsc functional form (__VLS_export as a generic function returning VNode), not DefineComponent<__VLS_Props, ...>.
Activity
coderabbitai commentedon Nov 19, 2026
🔗 Related PRs
#841 - fix: resolve component prop types w/ project that includes each component [merged]
#811 - feat!: port build internals from unbuild to tsdown [merged]
📝 Issue Planner
Check the box below or use the
@coderabbitai plancommand to generate an implementation plan and prompts that you can use with your favorite coding assistant.🧪 Issue enrichment is currently in open beta.
You can configure auto-planning by selecting labels in the issue_enrichment configuration.
To disable automatic issue enrichment, add the following to your
.coderabbit.yaml:💬 Have feedback or questions? Drop into our discord!