Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(runtime-core): force evalutating SetupContext type (fix #2362) #2818

Merged
merged 2 commits into from Nov 14, 2022

Conversation

sapphi-red
Copy link
Contributor

It seems like TypeScript does not evaluate type when it is in an object.

type IfAny<T> = T extends any ? true : false

type Box<T> = {
    value: IfAny<T>
}

declare let a: Box<number>
declare let b: Box<string>

a = b // error (Actually, both becomes `true` so it should be ok)

TS Playground

To fix #2362, I changed it using T extends any ? .

@netlify
Copy link

netlify bot commented Nov 14, 2022

Deploy Preview for vuejs-coverage failed.

Name Link
🔨 Latest commit 97437d7
🔍 Latest deploy log https://app.netlify.com/sites/vuejs-coverage/deploys/637209318cfaba000831d9b0

@yyx990803 yyx990803 merged commit eb2a832 into vuejs:main Nov 14, 2022
cexbrayat added a commit to cexbrayat/vue-test-utils-next that referenced this pull request Feb 2, 2023
A change of types in core (vuejs/core#2818) introduced a TS compilation error when bumping to Vue v3.2.47.
I couldn't figure out a proper way to fix, but using `EmitOptions` instead of `E` (which extends `EmitOptions`...) fixes the issue.
It may be good enough to allow to update to the latest Vue releases, and I think it should have minimal impact on our users (or none at all).
lmiller1990 pushed a commit to vuejs/test-utils that referenced this pull request Feb 2, 2023
* chore(deps): update all non-major dependencies

* fix: TS workaround for Vue v3.2.47

A change of types in core (vuejs/core#2818) introduced a TS compilation error when bumping to Vue v3.2.47.
I couldn't figure out a proper way to fix, but using `EmitOptions` instead of `E` (which extends `EmitOptions`...) fixes the issue.
It may be good enough to allow to update to the latest Vue releases, and I think it should have minimal impact on our users (or none at all).

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
chrislone pushed a commit to chrislone/core that referenced this pull request Feb 4, 2023
@unitydynamics
Copy link

unitydynamics commented Feb 11, 2023

This change broke userland types that extends SetupContext. My code that type-checks emit signatures no longer works.

I had this utility interface:

interface SetupContextExtended<Event extends Record<string, any>> extends SetupContext {
   emit: <Key extends keyof Event>(event: Key, payload: Event[Key]) => void;
}

And I was using it with event interface types to ensure emits were well type-checked.

Is there a more official way of type-checking emits now? I'm using old style script rather than script setup

zhangzhonghe pushed a commit to zhangzhonghe/core that referenced this pull request Apr 12, 2023
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.

Cannot assign narrower EmitsOption type
3 participants