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

Release 8.0.5 introduced errors. Argument of type 'ReactElement' is not assignable to parameter of type 'Element' #109

Open
yoriiis opened this issue Oct 8, 2024 · 3 comments

Comments

@yoriiis
Copy link

yoriiis commented Oct 8, 2024

Hello @alex-kinokon,

I use this package on several projects without any problems, but it seems that the latest version 8.1.5 has introduced some errors. The following code

// index.tsx
document.body.insertAdjacentElement('afterbegin', <div>Hello</div>)

generates this error

TS2345: Argument of type 'ReactElement' is not assignable to parameter of type 'Element'.
  Type 'DocumentFragment' is missing the following properties from type 'Element': attributes, classList, className, clientHeight, and 109 more.

With the previous version 8.1.4 there are no errors. I use the automatic runtime with jsx-dom-cjs.

I'm available if you need more info. Thanks to you

@alex-kinokon
Copy link
Owner

PR welcome.

@yoriiis
Copy link
Author

yoriiis commented Oct 9, 2024

In 6e0e7e8, the type of ReactElement has changed in the file index.d.ts#L61.

I tested without the | DocumentFragment and the TypeScript error does not appear locally with the following example.

document.body.insertAdjacentElement('afterbegin', <h1>OK</h1>)

However, I don't fully understand these changes and I don't know why the error appears in this example. I'd like to avoid creating another problem. Do you have more information?

Proposed changes:

# https://github.com/alex-kinokon/jsx-dom/blob/master/types/index.d.ts
- export type ReactElement = HTMLElement | SVGElement | DocumentFragment
+ export type ReactElement = HTMLElement | SVGElement

@alex-kinokon
Copy link
Owner

Please see #107.

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

No branches or pull requests

2 participants