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

Commit

Permalink
Make some more modules strict-local
Browse files Browse the repository at this point in the history
Summary:
Only change to logic involved not modifying an argument (since arguments are constant in flow strict).

Also fixes a lint (newline missing).

Reviewed By: gkz

Differential Revision: D18329130

fbshipit-source-id: 79007c6591cb9e0398924801496d580715aca7b4
  • Loading branch information
mrkev authored and facebook-github-bot committed Jan 30, 2020
1 parent 7002565 commit c30ca73
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ test('must remove styles', () => {
test('must add and remove styles accross multiple blocks', () => {
const nextBlock = contentState.getBlockAfter(selectionState.getStartKey());
const selection = selectionState.merge({
focusKey: nextBlock.getKey(),
focusOffset: nextBlock.getLength(),
focusKey: nextBlock?.getKey(),
focusOffset: nextBlock?.getLength(),
});

const modified = assertAddContentStateInlineStyle('BOLD', selection);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ const selectBlock = new SelectionState({
const selectAdjacentBlocks = new SelectionState({
anchorKey: initialBlock.getKey(),
anchorOffset: 0,
focusKey: secondBlock.getKey(),
focusOffset: secondBlock.getLength(),
focusKey: secondBlock?.getKey(),
focusOffset: secondBlock?.getLength(),
});

const assertApplyEntityToContentState = (
Expand Down
5 changes: 3 additions & 2 deletions src/model/transaction/applyEntityToContentBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*
* @format
* @flow
* @flow strict-local
* @emails oncall+draft_js
*/

Expand All @@ -17,10 +17,11 @@ const CharacterMetadata = require('CharacterMetadata');

function applyEntityToContentBlock(
contentBlock: BlockNodeRecord,
start: number,
startArg: number,
end: number,
entityKey: ?string,
): BlockNodeRecord {
let start = startArg;
let characterList = contentBlock.getCharacterList();
while (start < end) {
characterList = characterList.set(
Expand Down
8 changes: 6 additions & 2 deletions src/model/transaction/getSampleStateForTesting.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*
* @format
* @flow
* @flow strict-local
* @emails oncall+draft_js
*/

Expand Down Expand Up @@ -97,7 +97,11 @@ const contentState = new ContentState({
let editorState = EditorState.createWithContent(contentState);
editorState = EditorState.forceSelection(editorState, selectionState);

const getSampleStateForTesting = (): Object => {
const getSampleStateForTesting = (): {|
editorState: EditorState,
contentState: ContentState,
selectionState: SelectionState,
|} => {
return {editorState, contentState, selectionState};
};

Expand Down
4 changes: 2 additions & 2 deletions src/model/transaction/updateEntityDataInContentState.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*
* @format
* @flow
* @flow strict-local
* @emails oncall+draft_js
*/

Expand All @@ -16,7 +16,7 @@ import type ContentState from 'ContentState';
function updateEntityDataInContentState(
contentState: ContentState,
key: string,
data: {[key: string]: any, ...},
data: {[key: string]: mixed, ...},
merge: boolean,
): ContentState {
const instance = contentState.getEntity(key);
Expand Down

0 comments on commit c30ca73

Please sign in to comment.