Draft-js: Missing flow type for RawDraftContentState

Created on 25 Jan 2018  路  3Comments  路  Source: facebook/draft-js

Do you want to request a feature or report a bug?
Bug
What is the current behavior?
The type RawDraftContentState is not exported for public consumption. Currently, attempting to import this type causes a flow error:

Error: src/models/Question.js:10
 10: import type { RawDraftContentState } from "draft-js";
                   ^^^^^^^^^^^^^^^^^^^^ Named import from module `draft-js`. This module has no named export called `RawDraftContentState`.

Steps to reproduce
In an environment with draft-js and flow, do import type { RawDraftContentState } from "draft-js"; and run flow. Flow will give the above error.

What is the expected behavior?
I expect to be able to consume this type publicly, as it is required for use with the public API in convertFromRaw and convertToRaw.

Which versions of Draft.js, and which browser / OS are affected by this issue? Did this work in previous versions of Draft.js?
I encountered this with Draft at ^0.10.4 and flow-bin at ^0.63.1 on OSX.

Most helpful comment

Draft.js exports its Flow types in separate .flow files. You should be able to get this type from:

import type { RawDraftContentState } from 'draft-js/lib/RawDraftContentState.js.flow';

All 3 comments

Draft.js exports its Flow types in separate .flow files. You should be able to get this type from:

import type { RawDraftContentState } from 'draft-js/lib/RawDraftContentState.js.flow';

Thanks @thibaudcolas - this will vary depending on your build system and module system, and internally at Facebook we are able to import type {RawDraftContentState} from 'RawDraftContentState';, and likewise with any type that is prefaced with export in the source files of Draft.js. I think adding the export keyword is the main thing we could do in the source files to indicate that this is a publicly consumable type.

@flarnie Thank you! Is there any documentation about the available typing?

Was this page helpful?
0 / 5 - 0 ratings