Subscribe on changes!

types: the returned type of `resolveComponent` mismatch the argument type of `h`

avatar
Oct 12th 2020

Version

3.0.0

Reproduction link

https://codesandbox.io/s/polished-wind-py4gs?file=/src/index.ts

Steps to reproduce

click the reproduction link.

What is expected?

no type error.

What is actually happening?

type check failed.

avatar
Oct 12th 2020

const button = resolveComponent("my-button") as ComponentOptions; as workround.

avatar
Oct 12th 2020

@edison1105 Thanks for replying. your workaround works in the case above. but there is a case in which the paramerter passed to resolveComponent is dynamic:


//value of tagName can  be builtin html tag name such as 'div' or custom global component name 'my-button' for example. 
// in the former situation, type of resolveComponent(tagName) shoud be cast as `string`, while in the latter should be `ComponentOptions`.
const tagName = getTagName();  
resolveComponent(tagName);