Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add null return types to BlockRenderer and defaultBlockTag #201

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

pereznieto
Copy link

Description

This PR adds two null types to the TypeScript definition of draft-js-export-html: BlockRenderer and defaultBlockTag.
These null return types are present in the documentation (and code), but were missing from the TypeScript definition, thus causing type linting/compilation errors.
I decided to combine both changes in a single PR, as the changes are small and simple enough and touch the same file.

Changes

BlockRenderer

The docs state:

You can return a string to render this block yourself, or return nothing (null or undefined) to defer to the default renderer.

The possibility to return null or undefined was missing from the TypeScript definition, meaning it wasn't possible to defer to the default renderer in a BlockRenderer function.

defaultBlockTag

The docs state:

If you don't want any parent block tag, you can set defaultBlockTag to null.

The TypeScript definition didn't allow for this, as it required a string to be returned.

Related issues

@@ -5,15 +5,15 @@ declare module 'draft-js-export-html' {

type BlockStyleFn = (block: draftjs.ContentBlock) => RenderConfig|undefined;
type EntityStyleFn = (entity: draftjs.EntityInstance) => RenderConfig|undefined;
type BlockRenderer = (block: draftjs.ContentBlock) => string;
type BlockRenderer = (block: draftjs.ContentBlock) => string|null|undefined;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
type BlockRenderer = (block: draftjs.ContentBlock) => string|null|undefined;
type BlockRenderer = (block: draftjs.ContentBlock) => ?string;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants