Skip to content

fix(language-core): resolve generic constraints of setup bindings read in v-bind - #6336

Merged
johnsoncodehk merged 9 commits into
vuejs:masterfrom
ValentinYoushkevich:fix/generic-vbind-unwrap
Dec 3, 2026
Merged

johnsoncodehk merged 9 commits into
vuejs:masterfrom
ValentinYoushkevich:fix/generic-vbind-unwrap

Conversation

@ValentinYoushkevich

Copy link
Copy Markdown
Contributor

Since 3.3.12, v-bind of a generic-typed setup binding next to another attribute gives a false TS2345 (3.3.11 is fine). nuxt-ui has five of these, e.g. Sidebar.vue.

<script setup lang="ts" generic="T extends 'a' | 'b'">
const props = defineProps<{
	attrs: T extends 'a' ? { title?: string } : { hidden?: boolean };
}>();
const attrs = computed(() => props.attrs);
</script>

<template>
	<div id="foo" v-bind="attrs" />
</template>

#6184 reads the binding as __VLS_unwrap(attrs, ...). TS resolves a generic to its union constraint on references, not on call results, so the spread stays { id: string } & (T extends 'a' ? ...). The helper now returns a one-element tuple read through [0], and the template hover looks through that element access.

# Conflicts:
#	packages/language-core/types/template-helpers.d.ts
# Conflicts:
#	packages/language-core/types/template-helpers.d.ts
#	test-workspace/tsc/tsconfig.json
# Conflicts:
#	test-workspace/tsc/tsconfig.json
# Conflicts:
#	test-workspace/tsc/tsconfig.json
# Conflicts:
#	test-workspace/tsc/tsconfig.json
@johnsoncodehk
johnsoncodehk merged commit cf1b1fa into vuejs:master Dec 3, 2026
3 checks passed
@ValentinYoushkevich
ValentinYoushkevich deleted the fix/generic-vbind-unwrap branch December 4, 2026 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants