Html-react-parser: attributesToPropsの間違ったリターンタイプ

作成日 2021年04月16日  ·  5コメント  ·  ソース: remarkablemark/html-react-parser

説明

ファイルattributes-to-props.d.tsでは、 attributesToProps関数の戻りタイプはObjectStringアイテムが含まれています。

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

ただし、 attributesToProps関数では、 setStylePropが呼び出されてCSSInlineStyleObjectに変換されます。

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

関数の戻り値はStyleObjectであり、 Stringありません。

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

CSSPropertyを取得したい場合、この入力ミスの結果はエラーになります。

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

予想される行動

attributes-to-props.d.tsを次のように更新します:

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

全てのコメント5件

この問題を@EoleOで作成していただきありがとうございます。 PRを開きますか?

@EoleOは#245を確認してください

公開されたv1.2.6

npm

npm i [email protected]

毛糸

yarn add [email protected]

迅速に対応していただきありがとうございます

@EoleOもちろん、まだ問題が発生している場合は、お気軽に再開してください。

このページは役に立ちましたか?
0 / 5 - 0 評価