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

Type 'VNode<any> | VNode<any>[]' is not assignable to type 'VNode<any> | null' #3815

Open
zim32 opened this issue Nov 24, 2022 · 0 comments
Open
Labels

Comments

@zim32
Copy link

zim32 commented Nov 24, 2022

  • [x ] Check if updating to the latest Preact version resolves the issue

Describe the bug
When using htm with typescript I have types incompatibility

import {FunctionalComponent, h} from 'preact'
import htm from 'htm'

const html = htm.bind(h)

const TestComponent: FunctionalComponent<{ foo: number }> = ({ foo }) => {
    return html`<div>${foo}</div>`
}

Here typescript complains that

TS2322: Type '({ foo }: RenderableProps<{ foo: number; }, any>) => VNode<any> | VNode<any>[]' is not assignable to type 'FunctionalComponent<{ foo: number; }>'.   Type 'VNode<any> | VNode<any>[]' is not assignable to type 'VNode<any> | null'.     Type 'VNode<any>[]' is missing the following properties from type 'VNode<any>': type, props, key

Expected behavior
No type error.

Doing

return html`<div>${foo}</div>` as VNode<any>

resolves this issue but I think it will be better to change htm or FunctionalComponent declaration.

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

No branches or pull requests

2 participants