-
-
Notifications
You must be signed in to change notification settings - Fork 8.9k
Open
Labels
🍰 p2-nice-to-havePriority 2: this is not breaking anything but nice to have it addressed.Priority 2: this is not breaking anything but nice to have it addressed.scope: types
Description
Vue - Official extension or vue-tsc version
3.0.8
VSCode version
1.104.2
Vue version
3.5.13
TypeScript version
5.8.3
Steps to reproduce
Given the following emit definition:
const givenEmit = defineEmits<{
open: [payload: number];
close: [payload: string];
}>();
What is expected?
When I type givenEmit("open", ... )
I expect the following suggestion to be of type number
, but both number
and string
options are provided, as if no narrowing could be possible:
I expected the type of givenEmit
to be something like:
type ExpectedType = <
TEvent extends "open" | "close",
TEventArgs extends { open: [payload: number]; close: [payload: string] },
>(
event: TEvent,
...args: TEventArgs[TEvent]
) => void;
So that when I typed givenEmit("open", ... )
it would be able to narrow down the selected option, but this seems not to happen.
What is actually happening?
The type is being set as an intersection of all possible types, and therefore narrowing is not happening:

Link to minimal reproduction
No response
Any additional comments?
No response
Metadata
Metadata
Assignees
Labels
🍰 p2-nice-to-havePriority 2: this is not breaking anything but nice to have it addressed.Priority 2: this is not breaking anything but nice to have it addressed.scope: types