HubSpot / draft-convert

Extensibly serialize & deserialize Draft.js ContentState with HTML.
Apache License 2.0
483 stars 94 forks source link

TypeScript: Argument of type 'htmlConverter' is not assignable to parameter of type 'ContentState'. #173

Open anynines-johannchopin opened 4 years ago

anynines-johannchopin commented 4 years ago

Hey team 👋

I use convertFromHTML from draft-convert to convert my html string to an object that can be called as parameter from EditorState.createWithContent from draftjs (as explained in the README).

But when I do something like that:

const textToConvert = '<p>A paragraph</p>'
editorState = EditorState.createWithContent(convertFromHTML(textToConvert));
                                                            ~~~~~~~~~~~~~

I get a type definition error from TypeScript:

Type 'string' has no properties in common with type 'IConvertFromHTMLConfig'

Have I missed something because like that it's working pretty well 🤔

Here is the link of the sandbox