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

Overloads for render function cause needless check #5431

Closed
danielroe opened this issue Feb 15, 2022 · 0 comments · Fixed by #5432
Closed

Overloads for render function cause needless check #5431

danielroe opened this issue Feb 15, 2022 · 0 comments · Fixed by #5432

Comments

@danielroe
Copy link
Member

danielroe commented Feb 15, 2022

Version

3.2.31

Reproduction link

www.typescriptlang.org/play

import { h, Component } from 'vue'

const serializers = {
    Paragraph: 'p',
    Component: {} as Component<any>
}

const sampleComponent = serializers['' as keyof typeof serializers]

// This is a type error
h(sampleComponent)
h(sampleComponent, '')

// This isn't
if (typeof sampleComponent === 'string') {
    h(sampleComponent)
    h(sampleComponent, '')
} else {
    h(sampleComponent)
    h(sampleComponent, '')
}

Steps to reproduce

If we have a component to render that is string | Component we have to narrow its type even if we are calling h() in a way that doesn't make a difference.

What is expected?

I expect not to have to narrow the type in this instance.

What is actually happening?

I am having to add a needless check.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants