Skip to content
This repository has been archived by the owner on Feb 6, 2023. It is now read-only.

Commit

Permalink
Workaround for BlockNode variance issue caused by flow transform (#1621)
Browse files Browse the repository at this point in the history
Summary:
**Summary**

This should fix #1621 (it does in our project).

This manually transforms the BlockNode interface to use properties like the build step will do, but it adds covariant property annotations to match the expectation that classes have read-only methods. A better solution would be to fix the transform itself to do the right thing with interface methods, but this should be equivalent and is easier (for me) to do.

**Test Plan**

Confirm that the output lib/BlockNode.js.flow includes the covariant property annotations (`+`) before each of the properties that were previously methods. The automated test infrastructure only runs over src so it's harder to verify in travis as-is.
Closes #1683

Differential Revision: D7399839

fbshipit-source-id: 16fb390789f2ab7cff3781d854c6d9af900de906
  • Loading branch information
etrepum authored and facebook-github-bot committed Mar 26, 2018
1 parent 6eec8f9 commit 1d77500
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/model/immutable/BlockNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,31 +32,31 @@ export type BlockNodeConfig = {
// https://github.com/facebook/draft-js/issues/1492
// prettier-ignore
export interface BlockNode {
findEntityRanges(
+findEntityRanges: (
filterFn: (value: CharacterMetadata) => boolean,
callback: (start: number, end: number) => void,
): void,
) => void,

findStyleRanges(
+findStyleRanges: (
filterFn: (value: CharacterMetadata) => boolean,
callback: (start: number, end: number) => void,
): void,
) => void,

getCharacterList(): List<CharacterMetadata>,
+getCharacterList: () => List<CharacterMetadata>,

getData(): Map<any, any>,
+getData: () => Map<any, any>,

getDepth(): number,
+getDepth: () => number,

getEntityAt(offset: number): ?string,
+getEntityAt: (offset: number) => ?string,

getInlineStyleAt(offset: number): DraftInlineStyle,
+getInlineStyleAt: (offset: number) => DraftInlineStyle,

getKey(): BlockNodeKey,
+getKey: () => BlockNodeKey,

getLength(): number,
+getLength: () => number,

getText(): string,
+getText: () => string,

getType(): DraftBlockType,
+getType: () => DraftBlockType,
}

0 comments on commit 1d77500

Please sign in to comment.