Skip to content

fix: use JSX.Element for type definitions #146

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

Merged
merged 2 commits into from
Mar 28, 2020

Conversation

yunyu
Copy link
Contributor

@yunyu yunyu commented Mar 26, 2020

What is the motivation for this pull request?

This makes the library usable for non-React JSX implementations in TypeScript. JSX.Element is defined as React.ReactElement for the 'react' package, and is overridden by other JSX implementations. Fixes #145.

What is the current behavior?

Currently, trying to use html-react-parser with Preact in TS will result in a bunch of type errors.

What is the new behavior?

  • React.ReactElement is replaced with JSX.Element, which aliases to React.ReactElement for the current tests
  • The HTMLReactParser return value matches the domToReact return value, since the former returns the output of the latter

Checklist:

  • Tests

@coveralls
Copy link

coveralls commented Mar 26, 2020

Coverage Status

Coverage remained the same at 100.0% when pulling bae05c0 on yunyu:ylin/jsx-element-types into 8a63228 on remarkablemark:master.

Copy link
Owner

@remarkablemark remarkablemark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yunyu Thanks for opening this PR! Overall, it looks good. I left some minor/nitpick comments. Let me know what you think.

@remarkablemark remarkablemark added the bug Something isn't working label Mar 27, 2020
@yunyu yunyu force-pushed the ylin/jsx-element-types branch from 49c8822 to bae05c0 Compare March 27, 2020 01:29
@yunyu
Copy link
Contributor Author

yunyu commented Mar 27, 2020

@remarkablemark I've made the requested changes

Copy link
Owner

@remarkablemark remarkablemark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for making the changes @yunyu!

@remarkablemark remarkablemark merged commit 0da2807 into remarkablemark:master Mar 28, 2020
@remarkablemark
Copy link
Owner

remarkablemark commented Mar 28, 2020

I'll make a release later tonight


Published 0.10.3:

npm:

yarn:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

dom-to-react.d.ts should reference JSX.Element instead of React.ReactElement
3 participants