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

Commit 83edf02

Browse files
pakoitofacebook-github-bot
authored andcommitted
Add correct type annotations to DraftEditor.react.js
Summary: This diff fixes some debt introduced when the flow failed to infer the types of these functions when automatically annotating them with the Annotate_exports codemod. Reviewed By: rubennorte Differential Revision: D13431571 fbshipit-source-id: 53696e7e179b876ffc9d509406fe84e9a2bbb9af
1 parent 81f92ee commit 83edf02

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

src/component/base/DraftEditor.react.js

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,9 @@ class DraftEditor extends React.Component<DraftEditorProps, State> {
465465
* a specified scroll position (for cases like `cut` behavior where it should
466466
* be restored to a known position).
467467
*/
468-
focus: any = (scrollPosition?: DraftScrollPosition): void => {
468+
focus: (scrollPosition?: DraftScrollPosition) => void = (
469+
scrollPosition?: DraftScrollPosition,
470+
): void => {
469471
const {editorState} = this.props;
470472
const alreadyHasFocus = editorState.getSelection().getHasFocus();
471473
const editorNode = ReactDOM.findDOMNode(this.editor);
@@ -504,7 +506,7 @@ class DraftEditor extends React.Component<DraftEditorProps, State> {
504506
}
505507
};
506508

507-
blur: any = (): void => {
509+
blur: () => void = (): void => {
508510
const editorNode = ReactDOM.findDOMNode(this.editor);
509511
invariant(
510512
editorNode instanceof HTMLElement,
@@ -520,11 +522,11 @@ class DraftEditor extends React.Component<DraftEditorProps, State> {
520522
* handler module to ensure that DOM events are managed appropriately for
521523
* the active mode.
522524
*/
523-
setMode: any = (mode: DraftEditorModes): void => {
525+
setMode: DraftEditorModes => void = (mode: DraftEditorModes): void => {
524526
this._handler = handlerMap[mode];
525527
};
526528

527-
exitCurrentMode: any = (): void => {
529+
exitCurrentMode: () => void = (): void => {
528530
this.setMode('edit');
529531
};
530532

@@ -537,7 +539,9 @@ class DraftEditor extends React.Component<DraftEditorProps, State> {
537539
* reconciliation occurs on a version of the DOM that is synchronized with
538540
* our EditorState.
539541
*/
540-
restoreEditorDOM: any = (scrollPosition?: DraftScrollPosition): void => {
542+
restoreEditorDOM: (scrollPosition?: DraftScrollPosition) => void = (
543+
scrollPosition?: DraftScrollPosition,
544+
): void => {
541545
this.setState({contentsKey: this.state.contentsKey + 1}, () => {
542546
this.focus(scrollPosition);
543547
});
@@ -548,7 +552,7 @@ class DraftEditor extends React.Component<DraftEditorProps, State> {
548552
*
549553
* Set the clipboard state for a cut/copy event.
550554
*/
551-
setClipboard: any = (clipboard: ?BlockMap): void => {
555+
setClipboard: (?BlockMap) => void = (clipboard: ?BlockMap): void => {
552556
this._clipboard = clipboard;
553557
};
554558

@@ -557,7 +561,7 @@ class DraftEditor extends React.Component<DraftEditorProps, State> {
557561
*
558562
* Retrieve the clipboard state for a cut/copy event.
559563
*/
560-
getClipboard: any = (): ?BlockMap => {
564+
getClipboard: () => ?BlockMap = (): ?BlockMap => {
561565
return this._clipboard;
562566
};
563567

@@ -570,7 +574,7 @@ class DraftEditor extends React.Component<DraftEditorProps, State> {
570574
* an `onChange` prop to receive state updates passed along from this
571575
* function.
572576
*/
573-
update: any = (editorState: EditorState): void => {
577+
update: EditorState => void = (editorState: EditorState): void => {
574578
this._latestEditorState = editorState;
575579
this.props.onChange(editorState);
576580
};
@@ -580,14 +584,14 @@ class DraftEditor extends React.Component<DraftEditorProps, State> {
580584
* a dragged element enters and leaves the editor (or any of its children),
581585
* to determine when the dragged element absolutely leaves the editor.
582586
*/
583-
onDragEnter: any = (): void => {
587+
onDragEnter: () => void = (): void => {
584588
this._dragCount++;
585589
};
586590

587591
/**
588592
* See `onDragEnter()`.
589593
*/
590-
onDragLeave: any = (): void => {
594+
onDragLeave: () => void = (): void => {
591595
this._dragCount--;
592596
if (this._dragCount === 0) {
593597
this.exitCurrentMode();

0 commit comments

Comments
 (0)