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

feat: integrated vue-component-type-helpers #2026

Merged
merged 18 commits into from
Apr 15, 2023
Merged

Conversation

johnsoncodehk
Copy link
Member

@johnsoncodehk johnsoncodehk commented Apr 9, 2023

Use vue-component-type-helpers instead of infer component props / slots from DefineComponent.

vue-component-type-helpers is simple in itself, but it behaves in line with vue-component-meta.

Fixes #1973

@netlify
Copy link

netlify bot commented Apr 9, 2023

Deploy Preview for vue-test-utils-docs ready!

Name Link
🔨 Latest commit f2be9d5
🔍 Latest deploy log https://app.netlify.com/sites/vue-test-utils-docs/deploys/643513d7498c0e000890a71d
😎 Deploy Preview https://deploy-preview-2026--vue-test-utils-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@johnsoncodehk
Copy link
Member Author

johnsoncodehk commented Apr 9, 2023

I have removed node 14 test in this PR, because test failed, and vue-tsc is also given up node 14 after v.1.3 (vuejs/language-tools#2489).

Copy link
Member

@lmiller1990 lmiller1990 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, great. Any recommendation for the release notes? Eg "Improve slot type inference when using TypeScript" would be correct?

Looks like this vastly simplifies the types, thanks!

Copy link
Collaborator

@freakzlike freakzlike left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it. Good work 👍

src/index.ts Outdated Show resolved Hide resolved
Copy link
Member

@cexbrayat cexbrayat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@johnsoncodehk Thanks for working on this ♥️

src/index.ts Outdated Show resolved Hide resolved
tests/components/WithTeleportEmitsComp.vue Show resolved Hide resolved
src/mount.ts Outdated Show resolved Hide resolved
src/vueWrapper.ts Outdated Show resolved Hide resolved
@cexbrayat cexbrayat requested a review from pikax April 10, 2023 08:25
@cexbrayat
Copy link
Member

@pikax If you have some time Carlos, it would be great to have your input as you worked on the original types

@cexbrayat
Copy link
Member

@lmiller1990 As this has the potential to be fairly breaking (I hope not), we should cut an alpha release for this to give it a try when merged

@lmiller1990
Copy link
Member

Hmm good point on the breaking change - it would be really ideal not to. Test Utils has never had a breaking change - and if it's just type definitions, this doesn't feel like a very compelling reason to break that pattern. I hope we can reassemble a kind of ComponentMountOptions type using vue-component-type-helpers?

@johnsoncodehk johnsoncodehk marked this pull request as draft April 10, 2023 12:54
@johnsoncodehk johnsoncodehk marked this pull request as ready for review April 10, 2023 22:37
@johnsoncodehk
Copy link
Member Author

Also merged the remaining overloads, since this is a breaking change anyway.

Compared with the original PR, the change may be quite radical now, if this does not meet expectations, please feel free to revert 3228334.

@lmiller1990
Copy link
Member

Thanks @johnsoncodehk - please give us a bit to figure out how to handle a breaking change. We haven't had one before, so we don't have a process around it, but we can do so if it'll improve the library for everyone.

@cexbrayat
Copy link
Member

Changes look good to me.
Once merged, maybe we could cut a 2.4 alpha release to see if that deserves a 3.0 release or not?
We'll also be able to check if that fixes #1973 and the bump to TS v5

@pikax
Copy link
Member

pikax commented Apr 11, 2023

It simplifies a lot, but there's some broken things:

const a = mount(
  defineComponent({
    props: ['hello'],
    data() {
      return {
        a: 1
      }
    },
    computed: {
      b() {
        return 0
      }
    }
  }),
  {
    data() {
      return {
        b: 12 // this should break the component since is not data
      }
    }
  }
)

On this PR:
image

Main branch:
image

@johnsoncodehk
Copy link
Member Author

@pikax thanks for reporting that, can you try this latest commit?

Since I haven't worked on this repo in the past, these modifications may be rather naive, please feel free to edit the PR if found something else breaks.

@pikax
Copy link
Member

pikax commented Apr 11, 2023

@johnsoncodehk I can confirm it's fixed, LGTM

Copy link
Collaborator

@freakzlike freakzlike left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

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.

"vue-tsc" fails with "error TS2769: No overload matches this call" in "strict" mode
5 participants