-
-
Notifications
You must be signed in to change notification settings - Fork 484
Closed
Closed
Copy link
Labels
enhancementNew feature or requestNew feature or request
Description
Vue - Official extension or vue-tsc version
Same as playground
Vue version
3.5.0-beta.1
TypeScript version
5.6.0-beta
System Info
No response
Steps to reproduce
<template>
<!--
vue-tsc failed to infer type of T
Type '(newUser: User) => void' is not assignable to type '(newValue: { id: number; }) => void'.
Types of parameters 'newUser' and 'newValue' are incompatible.ts(2322)
-->
<div v-example="[user, setUser]"></div>
</template>
<script lang="ts" setup>
import { ref } from "vue";
type User = {
id: number;
name: string;
};
const user = ref<User>({ id: 0, name: "User" });
function setUser(newUser: User) {
user.value = newUser;
}
const vExample = {
mounted<T extends { id: number }>(
_elContainingTbody: HTMLElement,
_binding: { value: [T, (newValue: T) => void] }
) { },
};
// T is inferred correctly by TypeScript
vExample.mounted(
document.createElement("div"),
{ value: [user.value, setUser] }
)
</script>
What is expected?
vue-tsc should infer the type of T correctly in the template.
What is actually happening?
Type '(newUser: User) => void' is not assignable to type '(newValue: { id: number; }) => void'.
Types of parameters 'newUser' and 'newValue' are incompatible.ts(2322)
Link to minimal reproduction
Any additional comments?
No response
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request