Skip to content

fix: use JSX.Element for type definitions#146

Merged
remarkablemark merged 2 commits intoremarkablemark:masterfrom
yunyu:ylin/jsx-element-types
Mar 28, 2020
Merged

fix: use JSX.Element for type definitions#146
remarkablemark merged 2 commits intoremarkablemark:masterfrom
yunyu:ylin/jsx-element-types

Conversation

@yunyu
Copy link
Copy Markdown
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
Copy Markdown

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
Copy Markdown
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
Copy Markdown
Contributor Author

yunyu commented Mar 27, 2020

@remarkablemark I've made the requested changes

Copy link
Copy Markdown
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
Copy Markdown
Owner

remarkablemark commented Mar 28, 2020

I'll make a release later tonight


Published 0.10.3:

npm:

npm i -S html-react-parser@0.10.3

yarn:

yarn add html-react-parser@0.10.3

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