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

types: making defineComponent return a valid Component type fix #993 #1032

Merged
merged 2 commits into from
Apr 24, 2020

Conversation

pikax
Copy link
Member

@pikax pikax commented Apr 22, 2020

Fixes #993

const Comp = defineComponent({
  setup() {
    return {};
  }
});

export const someComponents: Component[] = [Comp]; //error

@@ -30,7 +31,7 @@ describe('Suspense', () => {
setup(props: any, { slots }: any) {
const p = new Promise(resolve => {
setTimeout(() => {
resolve(() => h(comp, props, slots))
resolve(() => h<Component>(comp, props, slots))
Copy link
Member Author

Choose a reason for hiding this comment

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

I dont know if is possible do this without casting

@pikax pikax changed the title types: making defineComponent return a valid Component type types: making defineComponent return a valid Component type fix #993 Apr 22, 2020
@yyx990803
Copy link
Member

This should make PublicAPIComponent unnecessary, right?

@yyx990803 yyx990803 merged commit f3a9b51 into vuejs:master Apr 24, 2020
yyx990803 added a commit that referenced this pull request Apr 24, 2020
@pikax
Copy link
Member Author

pikax commented Apr 24, 2020

Not necessarily, because ClassComponent is not part of Component, only h needs special typing to provide props validations, PublicAPIComponent can't be used in h because is quite generic and everything would fall under that overload.

That said, for the exposed APIs I think is much better using PublicAPIComponent, probably renaming it to Component and rename Component to InternalAPIComponent(or better name) would make more sense to the user.

pikax added a commit to pikax/vue-next that referenced this pull request Apr 29, 2020
@pikax pikax deleted the types/component branch May 6, 2020 07:54
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.

TS: defineComponent doesn't return a Component
2 participants