Skip to content

Overloads for render function cause needless check #5431

@danielroe

Description

@danielroe

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy