Html-react-parser: Wrong return types on attributesToProps

Created on 16 Apr 2021  ·  5Comments  ·  Source: remarkablemark/html-react-parser

Description

In the file attributes-to-props.d.ts the return types of attributesToProps function is a Object with String items.

https://github.com/remarkablemark/html-react-parser/blob/80bbea06fac6825f2667060f979fbd54b407e748/lib/attributes-to-props.d.ts#L3-L4

But in the attributesToProps function, setStyleProp is call to transform CSSInline to StyleObject.

https://github.com/remarkablemark/html-react-parser/blob/80bbea06fac6825f2667060f979fbd54b407e748/lib/attributes-to-props.js#L62

The return of the function is an StyleObject and not a String.

https://github.com/remarkablemark/html-react-parser/blob/80bbea06fac6825f2667060f979fbd54b407e748/lib/utilities.js#L76-L87

The result of this miss-typing is an error if you would like to get an CSSProperty.

Capture d’écran 2021-04-16 à 10 42 51

Expected Behavior

Update attributes-to-props.d.ts with :

export type Attributes = Record<string, string>; 
export type Props = Record<string, string> & {
  style: Record<string, string>;
}; 
bug

All 5 comments

Thanks for creating this issue @EoleO. Would you like to open a PR?

@EoleO please review #245

Published v1.2.6:

npm:

npm i [email protected]

Yarn:

yarn add [email protected]

Thank you for your responsiveness

@EoleO Of course, feel free to reopen if you are still experiencing an issue.

Was this page helpful?
0 / 5 - 0 ratings