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

Commit

Permalink
Make decodeEntityRanges flow strict
Browse files Browse the repository at this point in the history
Summary: Functionality shouldn't have changed, I just editeed types. I did have to edit and re-record a test that was wrong.

Differential Revision: D19868736

fbshipit-source-id: e65885cd4565756e6669a17692e2f63d46f0d730
  • Loading branch information
mrkev authored and facebook-github-bot committed Feb 13, 2020
1 parent d6527a9 commit 7af73b7
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 27 deletions.
Expand Up @@ -4,8 +4,8 @@ exports[`must decode when an entity is present 1`] = `
Array [
null,
null,
"6",
"6",
6,
6,
null,
]
`;
Expand All @@ -14,11 +14,11 @@ exports[`must decode when an entity is present more than once 1`] = `
Array [
null,
null,
"6",
"6",
6,
6,
null,
"6",
"6",
6,
6,
null,
]
`;
Expand All @@ -27,11 +27,11 @@ exports[`must decode when multiple entities present 1`] = `
Array [
null,
null,
"6",
"6",
6,
6,
null,
"8",
"8",
8,
8,
null,
]
`;
Expand Down Expand Up @@ -69,16 +69,16 @@ Array [
null,
null,
null,
"6",
"6",
"6",
"6",
"6",
"6",
6,
6,
6,
6,
6,
6,
null,
null,
"8",
"8",
8,
8,
null,
]
`;
14 changes: 7 additions & 7 deletions src/model/encoding/__tests__/decodeEntityRanges-test.js
Expand Up @@ -23,7 +23,7 @@ test('must decode when an entity is present', () => {
{
offset: 2,
length: 2,
key: '6',
key: 6,
},
]);
expect(decoded).toMatchSnapshot();
Expand All @@ -34,12 +34,12 @@ test('must decode when multiple entities present', () => {
{
offset: 2,
length: 2,
key: '6',
key: 6,
},
{
offset: 5,
length: 2,
key: '8',
key: 8,
},
]);
expect(decoded).toMatchSnapshot();
Expand All @@ -50,12 +50,12 @@ test('must decode when an entity is present more than once', () => {
{
offset: 2,
length: 2,
key: '6',
key: 6,
},
{
offset: 5,
length: 2,
key: '6',
key: 6,
},
]);
expect(decoded).toMatchSnapshot();
Expand All @@ -66,12 +66,12 @@ test('must handle ranges that include surrogate pairs', () => {
{
offset: 6,
length: 5,
key: '6',
key: 6,
},
{
offset: 13,
length: 2,
key: '8',
key: 8,
},
]);
expect(decoded).toMatchSnapshot();
Expand Down
6 changes: 4 additions & 2 deletions src/model/encoding/decodeEntityRanges.js
Expand Up @@ -5,12 +5,14 @@
* LICENSE file in the root directory of this source tree.
*
* @format
* @flow
* @flow strict
* @emails oncall+draft_js
*/

'use strict';

import type {EntityRange} from 'EntityRange';

const UnicodeUtils = require('UnicodeUtils');

const {substr} = UnicodeUtils;
Expand All @@ -20,7 +22,7 @@ const {substr} = UnicodeUtils;
*/
function decodeEntityRanges(
text: string,
ranges: Array<Object>,
ranges: Array<EntityRange>,
): Array<?string> {
const entities = Array(text.length).fill(null);
if (ranges) {
Expand Down

0 comments on commit 7af73b7

Please sign in to comment.