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(type): improve defineComponent type for option apis #406

Merged
merged 2 commits into from Jun 24, 2020

Conversation

antfu
Copy link
Member

@antfu antfu commented Jun 23, 2020

Resolve #338, Resolve #191

This should fix the most common use cases for type inference in defineComponent. Type inference of mixins and emit is not implemented in this PR.

@antfu antfu marked this pull request as draft June 23, 2020 18:19
@antfu antfu marked this pull request as ready for review June 23, 2020 18:29
@antfu antfu force-pushed the fix/type-define-component branch from 1cb270e to 2d8b0cc Compare June 23, 2020 19:06
@antfu
Copy link
Member Author

antfu commented Jun 23, 2020

@pikax Can you help review a bit? Sorry for being kinda huge.

I took a lot of code from vue-next as references. I also copied the defineComponent.test-d.ts from it, except for the mixins and emit parts. Tests are passing, so I think it should work fine. Just pinning you to be sure. Thank you.

This was hard and I have to say I learned Typescript better 😅

@antfu antfu mentioned this pull request Jun 23, 2020
@Aaron-Pool
Copy link

Thanks so much for getting a quick PR for this going, @antfu! It's super appreciated 🙇

@antfu antfu force-pushed the fix/type-define-component branch from 2d8b0cc to 3c3dc80 Compare June 24, 2020 09:56
@antfu antfu changed the base branch from rc to master June 24, 2020 09:56
@antfu
Copy link
Member Author

antfu commented Jun 24, 2020

Force pushed to against master as this is not a breaking change. We can release the fix before 1.0.

Copy link
Member

@pikax pikax 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.

TypeScript with composition-api: in methods, "this" is Vue, not current instance Access Data in render
3 participants