You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There's a types inference regression introduced by #3507 for createEventHook listeners/triggers.
Previously arguments in on listeners would be correctly inferred from the type argument of createEventHook function. Today it will resolve to any when type argument is a union type. For projects with noImplicitAny enabled it now triggers an error.
It's also possible to omit arguments for trigger completely even though createEventHook was declared with a single type argument. See provided TS playground links.
Using typescript v5.2.2.
// 10.5.0constnumberOrStringHook=createEventHook<number|string>();numberOrStringHook.on(value=>{// value: number | string});// error: Expected 1 arguments, but got 0.numberOrStringHook.trigger();
Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
Make sure this is a VueUse issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/core instead.
Check that this is a concrete bug. For Q&A open a GitHub Discussion.
Describe the bug
There's a types inference regression introduced by #3507 for
createEventHook
listeners/triggers.Previously arguments in
on
listeners would be correctly inferred from the type argument ofcreateEventHook
function. Today it will resolve toany
when type argument is a union type. For projects withnoImplicitAny
enabled it now triggers an error.It's also possible to omit arguments for
trigger
completely even thoughcreateEventHook
was declared with a single type argument. See provided TS playground links.Using typescript v5.2.2.
playground link
playground link
It also affected
useFileDialog.onChange
playground link
Reproduction
https://www.typescriptlang.org/play?#code/JYWwDg9gTgLgBAbzgYygUwIYzQUQG5oB2MAEhBANZwC+cAZlBCHAEQACeArmpwM5oB6XgAsM6ACYsA3HAEC4MAJ5g0vAFxwAjAAYAdADZdmgLAAoM8giFe8QpxAAjNFDKU4AXhTosuAsVcUADx2js4AfAAUAJRSZiFOLuQUulYREXgYADbcUR5hiGZwRcUlpbICAHoA-GbUUWZx9gkBujBQwADmHc4RmjGNoYmUre1dPSw27YQdLP2m8c4tbZ3dUNGx802LSSMrPQh1GxZWNnALUADyUADKy9MBHl6Y2PhEpEnBW1BwAD5wk8BppE5ucrrcph0Wql0lkcnkCqYykjkeVqrV6uZNoMwXdITtlmM1n0NqCbrilqNVhEJrjZiSvjiIRS9msQQyyUz8ZT9ocGpjLNZ4HgIMBxA9PKhnr43gF1mZhaKoYQ0hlsmhcu58ghCiiinI0aY6nyFWKuSzenMTczCdSAdM6fKRabhgSqZandaqQc5kA
System Info
Used Package Manager
yarn
Validations
The text was updated successfully, but these errors were encountered: