Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8af0127

Browse filesBrowse files
authored
Update to latest flow (immutable-js#1531)
* Update to latest yarn * Flow v81 * Update to fix remaining issues and block out bugs the tests expose
1 parent 73a9886 commit 8af0127
Copy full SHA for 8af0127

File tree

Expand file treeCollapse file tree

6 files changed

+82
-80
lines changed
Filter options
Expand file treeCollapse file tree

6 files changed

+82
-80
lines changed

‎package.json

Copy file name to clipboardExpand all lines: package.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
"eslint-plugin-jsx-a11y": "6.0.3",
7272
"eslint-plugin-prettier": "2.6.0",
7373
"eslint-plugin-react": "7.8.2",
74-
"flow-bin": "0.56.0",
74+
"flow-bin": "0.81.0",
7575
"gulp": "3.9.1",
7676
"gulp-concat": "2.6.1",
7777
"gulp-filter": "5.1.0",

‎type-definitions/immutable.js.flow

Copy file name to clipboardExpand all lines: type-definitions/immutable.js.flow
+44-44Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
// Helper type that represents plain objects allowed as arguments to
3232
// some constructors and functions.
33-
type PlainObjInput<K, V> = {[key: K]: V, __proto__: null};
33+
type PlainObjInput<K, V> = {+[key: K]: V, __proto__: null};
3434

3535
// Helper types to extract the "keys" and "values" use by the *In() methods.
3636
type $KeyOf<C> = $Call<
@@ -55,7 +55,7 @@ type $IterableOf<C> = $Call<
5555
C
5656
>;
5757

58-
declare class _Collection<K, +V> /*implements ValueObject*/ {
58+
declare class _Collection<K, +V> implements ValueObject {
5959
equals(other: mixed): boolean;
6060
hashCode(): number;
6161
get(key: K, ..._: []): V | void;
@@ -1376,7 +1376,7 @@ declare function Repeat<T>(value: T, times?: number): IndexedSeq<T>;
13761376
type RecordFactory<Values: Object> = Class<RecordInstance<Values>>;
13771377

13781378
// The type of runtime Record instances.
1379-
type RecordOf<Values: Object> = RecordInstance<Values> & Values;
1379+
type RecordOf<Values: Object> = RecordInstance<Values> & $ReadOnly<Values>;
13801380

13811381
// The values of a Record instance.
13821382
type _RecordValues<T, R: RecordInstance<T> | T> = R;
@@ -1407,7 +1407,7 @@ declare class RecordInstance<T: Object> {
14071407

14081408
hasIn(keyPath: Iterable<mixed>): boolean;
14091409

1410-
getIn(keyPath: [], notSetValue?: mixed): this & T;
1410+
getIn(keyPath: [], notSetValue?: mixed): this & $ReadOnly<T>;
14111411
getIn<K: $Keys<T>>(keyPath: [K], notSetValue?: mixed): $ElementType<T, K>;
14121412
getIn<NSV, K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>>(keyPath: [K, K2], notSetValue: NSV): $ValOf<$ValOf<T, K>, K2> | NSV;
14131413
getIn<NSV, K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>, K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>>(keyPath: [K, K2, K3], notSetValue: NSV): $ValOf<$ValOf<$ValOf<T, K>, K2>, K3> | NSV;
@@ -1417,71 +1417,71 @@ declare class RecordInstance<T: Object> {
14171417
equals(other: any): boolean;
14181418
hashCode(): number;
14191419

1420-
set<K: $Keys<T>>(key: K, value: $ElementType<T, K>): this & T;
1421-
update<K: $Keys<T>>(key: K, updater: (value: $ElementType<T, K>) => $ElementType<T, K>): this & T;
1422-
merge(...collections: Array<Iterable<[$Keys<T>, $ValOf<T>]> | $Shape<T>>): this & T;
1423-
mergeDeep(...collections: Array<Iterable<[$Keys<T>, $ValOf<T>]> | $Shape<T>>): this & T;
1420+
set<K: $Keys<T>>(key: K, value: $ElementType<T, K>): this & $ReadOnly<T>;
1421+
update<K: $Keys<T>>(key: K, updater: (value: $ElementType<T, K>) => $ElementType<T, K>): this & $ReadOnly<T>;
1422+
merge(...collections: Array<Iterable<[$Keys<T>, $ValOf<T>]> | $Shape<T>>): this & $ReadOnly<T>;
1423+
mergeDeep(...collections: Array<Iterable<[$Keys<T>, $ValOf<T>]> | $Shape<T>>): this & $ReadOnly<T>;
14241424

14251425
mergeWith(
14261426
merger: (oldVal: $ValOf<T>, newVal: $ValOf<T>, key: $Keys<T>) => $ValOf<T>,
14271427
...collections: Array<Iterable<[$Keys<T>, $ValOf<T>]> | $Shape<T>>
1428-
): this & T;
1428+
): this & $ReadOnly<T>;
14291429
mergeDeepWith(
14301430
merger: (oldVal: any, newVal: any, key: any) => any,
14311431
...collections: Array<Iterable<[$Keys<T>, $ValOf<T>]> | $Shape<T>>
1432-
): this & T;
1432+
): this & $ReadOnly<T>;
14331433

1434-
delete<K: $Keys<T>>(key: K): this & T;
1435-
remove<K: $Keys<T>>(key: K): this & T;
1436-
clear(): this & T;
1434+
delete<K: $Keys<T>>(key: K): this & $ReadOnly<T>;
1435+
remove<K: $Keys<T>>(key: K): this & $ReadOnly<T>;
1436+
clear(): this & $ReadOnly<T>;
14371437

14381438
setIn<S>(keyPath: [], value: S): S;
1439-
setIn<K: $Keys<T>, S: $ValOf<T, K>>(keyPath: [K], value: S): this & T;
1440-
setIn<K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>, S: $ValOf<$ValOf<T, K>, K2>>(keyPath: [K, K2], value: S): this & T;
1441-
setIn<K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>, K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>, S: $ValOf<$ValOf<$ValOf<T, K>, K2>, K3>>(keyPath: [K, K2, K3], value: S): this & T;
1442-
setIn<K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>, K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>>, S: $ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>>(keyPath: [K, K2, K3, K4], value: S): this & T;
1443-
setIn<K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>, K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>>, S: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>, K5>>(keyPath: [K, K2, K3, K4, K5], value: S): this & T;
1439+
setIn<K: $Keys<T>, S: $ValOf<T, K>>(keyPath: [K], value: S): this & $ReadOnly<T>;
1440+
setIn<K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>, S: $ValOf<$ValOf<T, K>, K2>>(keyPath: [K, K2], value: S): this & $ReadOnly<T>;
1441+
setIn<K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>, K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>, S: $ValOf<$ValOf<$ValOf<T, K>, K2>, K3>>(keyPath: [K, K2, K3], value: S): this & $ReadOnly<T>;
1442+
setIn<K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>, K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>>, S: $ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>>(keyPath: [K, K2, K3, K4], value: S): this & $ReadOnly<T>;
1443+
setIn<K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>, K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>>, S: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>, K5>>(keyPath: [K, K2, K3, K4, K5], value: S): this & $ReadOnly<T>;
14441444

14451445
deleteIn(keyPath: []): void;
1446-
deleteIn<K: $Keys<T>>(keyPath: [K]): this & T;
1447-
deleteIn<K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>>(keyPath: [K, K2]): this & T;
1448-
deleteIn<K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>, K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>>(keyPath: [K, K2, K3]): this & T;
1449-
deleteIn<K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>, K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>>>(keyPath: [K, K2, K3, K4]): this & T;
1450-
deleteIn<K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>, K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>>>(keyPath: [K, K2, K3, K4, K5]): this & T;
1446+
deleteIn<K: $Keys<T>>(keyPath: [K]): this & $ReadOnly<T>;
1447+
deleteIn<K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>>(keyPath: [K, K2]): this & $ReadOnly<T>;
1448+
deleteIn<K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>, K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>>(keyPath: [K, K2, K3]): this & $ReadOnly<T>;
1449+
deleteIn<K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>, K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>>>(keyPath: [K, K2, K3, K4]): this & $ReadOnly<T>;
1450+
deleteIn<K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>, K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>>>(keyPath: [K, K2, K3, K4, K5]): this & $ReadOnly<T>;
14511451

14521452
removeIn(keyPath: []): void;
1453-
removeIn<K: $Keys<T>>(keyPath: [K]): this & T;
1454-
removeIn<K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>>(keyPath: [K, K2]): this & T;
1455-
removeIn<K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>, K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>>(keyPath: [K, K2, K3]): this & T;
1456-
removeIn<K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>, K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>>>(keyPath: [K, K2, K3, K4]): this & T;
1457-
removeIn<K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>, K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>>>(keyPath: [K, K2, K3, K4, K5]): this & T;
1453+
removeIn<K: $Keys<T>>(keyPath: [K]): this & $ReadOnly<T>;
1454+
removeIn<K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>>(keyPath: [K, K2]): this & $ReadOnly<T>;
1455+
removeIn<K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>, K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>>(keyPath: [K, K2, K3]): this & $ReadOnly<T>;
1456+
removeIn<K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>, K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>>>(keyPath: [K, K2, K3, K4]): this & $ReadOnly<T>;
1457+
removeIn<K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>, K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>>>(keyPath: [K, K2, K3, K4, K5]): this & $ReadOnly<T>;
14581458

14591459
updateIn<U>(keyPath: [], notSetValue: mixed, updater: (value: this & T) => U): U;
14601460
updateIn<U>(keyPath: [], updater: (value: this & T) => U): U;
1461-
updateIn<NSV, K: $Keys<T>, S: $ValOf<T, K>>(keyPath: [K], notSetValue: NSV, updater: (value: $ValOf<T, K>) => S): this & T;
1462-
updateIn<K: $Keys<T>, S: $ValOf<T, K>>(keyPath: [K], updater: (value: $ValOf<T, K>) => S): this & T;
1463-
updateIn<NSV, K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>, S: $ValOf<$ValOf<T, K>, K2>>(keyPath: [K, K2], notSetValue: NSV, updater: (value: $ValOf<$ValOf<T, K>, K2> | NSV) => S): this & T;
1464-
updateIn<K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>, S: $ValOf<$ValOf<T, K>, K2>>(keyPath: [K, K2], updater: (value: $ValOf<$ValOf<T, K>, K2>) => S): this & T;
1465-
updateIn<NSV, K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>, K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>, S: $ValOf<$ValOf<$ValOf<T, K>, K2>, K3>>(keyPath: [K, K2, K3], notSetValue: NSV, updater: (value: $ValOf<$ValOf<$ValOf<T, K>, K2>, K3> | NSV) => S): this & T;
1466-
updateIn<K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>, K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>, S: $ValOf<$ValOf<$ValOf<T, K>, K2>, K3>>(keyPath: [K, K2, K3], updater: (value: $ValOf<$ValOf<$ValOf<T, K>, K2>, K3>) => S): this & T;
1467-
updateIn<NSV, K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>, K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>>, S: $ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>>(keyPath: [K, K2, K3, K4], notSetValue: NSV, updater: (value: $ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4> | NSV) => S): this & T;
1468-
updateIn<K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>, K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>>, S: $ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>>(keyPath: [K, K2, K3, K4], updater: (value: $ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>) => S): this & T;
1469-
updateIn<NSV, K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>, K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>>, S: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>, K5>>(keyPath: [K, K2, K3, K4, K5], notSetValue: NSV, updater: (value: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>, K5> | NSV) => S): this & T;
1470-
updateIn<K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>, K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>>, S: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>, K5>>(keyPath: [K, K2, K3, K4, K5], updater: (value: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>, K5>) => S): this & T;
1471-
1472-
mergeIn(keyPath: Iterable<mixed>, ...collections: Array<any>): this & T;
1473-
mergeDeepIn(keyPath: Iterable<mixed>, ...collections: Array<any>): this & T;
1461+
updateIn<NSV, K: $Keys<T>, S: $ValOf<T, K>>(keyPath: [K], notSetValue: NSV, updater: (value: $ValOf<T, K>) => S): this & $ReadOnly<T>;
1462+
updateIn<K: $Keys<T>, S: $ValOf<T, K>>(keyPath: [K], updater: (value: $ValOf<T, K>) => S): this & $ReadOnly<T>;
1463+
updateIn<NSV, K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>, S: $ValOf<$ValOf<T, K>, K2>>(keyPath: [K, K2], notSetValue: NSV, updater: (value: $ValOf<$ValOf<T, K>, K2> | NSV) => S): this & $ReadOnly<T>;
1464+
updateIn<K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>, S: $ValOf<$ValOf<T, K>, K2>>(keyPath: [K, K2], updater: (value: $ValOf<$ValOf<T, K>, K2>) => S): this & $ReadOnly<T>;
1465+
updateIn<NSV, K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>, K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>, S: $ValOf<$ValOf<$ValOf<T, K>, K2>, K3>>(keyPath: [K, K2, K3], notSetValue: NSV, updater: (value: $ValOf<$ValOf<$ValOf<T, K>, K2>, K3> | NSV) => S): this & $ReadOnly<T>;
1466+
updateIn<K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>, K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>, S: $ValOf<$ValOf<$ValOf<T, K>, K2>, K3>>(keyPath: [K, K2, K3], updater: (value: $ValOf<$ValOf<$ValOf<T, K>, K2>, K3>) => S): this & $ReadOnly<T>;
1467+
updateIn<NSV, K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>, K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>>, S: $ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>>(keyPath: [K, K2, K3, K4], notSetValue: NSV, updater: (value: $ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4> | NSV) => S): this & $ReadOnly<T>;
1468+
updateIn<K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>, K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>>, S: $ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>>(keyPath: [K, K2, K3, K4], updater: (value: $ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>) => S): this & $ReadOnly<T>;
1469+
updateIn<NSV, K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>, K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>>, S: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>, K5>>(keyPath: [K, K2, K3, K4, K5], notSetValue: NSV, updater: (value: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>, K5> | NSV) => S): this & $ReadOnly<T>;
1470+
updateIn<K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>, K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>>, S: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>, K5>>(keyPath: [K, K2, K3, K4, K5], updater: (value: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>, K5>) => S): this & $ReadOnly<T>;
1471+
1472+
mergeIn(keyPath: Iterable<mixed>, ...collections: Array<any>): this & $ReadOnly<T>;
1473+
mergeDeepIn(keyPath: Iterable<mixed>, ...collections: Array<any>): this & $ReadOnly<T>;
14741474

14751475
toSeq(): KeyedSeq<$Keys<T>, any>;
14761476

14771477
toJS(): { [key: $Keys<T>]: mixed };
14781478
toJSON(): T;
14791479
toObject(): T;
14801480

1481-
withMutations(mutator: (mutable: this & T) => mixed): this & T;
1482-
asMutable(): this & T;
1481+
withMutations(mutator: (mutable: this & T) => mixed): this & $ReadOnly<T>;
1482+
asMutable(): this & $ReadOnly<T>;
14831483
wasAltered(): boolean;
1484-
asImmutable(): this & T;
1484+
asImmutable(): this & $ReadOnly<T>;
14851485

14861486
@@iterator(): Iterator<[$Keys<T>, $ValOf<T>]>;
14871487
}

‎type-definitions/tests/immutable-flow.js

Copy file name to clipboardExpand all lines: type-definitions/tests/immutable-flow.js
+8-9Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@ numberList = List.of('a').merge(List.of(1))
180180
// Functional API
181181

182182
numberList = merge(List([1]), List([2]))
183-
// $ExpectError - Functional API currently requires arguments to have the same value types.
184183
numberOrStringList = merge(List(['a']), List([1]))
185184
// $ExpectError
186185
numberList = merge(List(['a']), List([1]))
@@ -291,7 +290,7 @@ stringToNumber = set(set(Map({'a': 0}), 'b', 1), 'c', 2)
291290
stringOrNumberToNumberOrString = set(set(Map({'a': 'a'}), 'b', 1), 2, 'c')
292291
// $ExpectError
293292
stringToNumber = set(Map({'a': 0}), 'b', '')
294-
// TODO: This should be ExpectError, but Map() is Map<any, any>
293+
// $ExpectError
295294
stringToNumber = set(Map(), 1, '')
296295

297296
stringToNumber = Map({'a': 0}).delete('a')
@@ -581,9 +580,7 @@ orderedStringToNumber = OrderedMap({'a': 1}).map(() => 'a')
581580
orderedStringToString = OrderedMap({'a': 1}).map(() => 'a')
582581

583582
orderedStringToNumber = OrderedMap({'a': 1}).flatMap((v, k) => (OrderedMap({ [k]: v + 1 })))
584-
/**
585-
* FIXME: this should throw an error, it's an OrderedMap<string, string>
586-
*/
583+
// $ExpectError - string "a" is not a number
587584
orderedStringToNumber = OrderedMap({'a': 1}).flatMap((v, k) => (OrderedMap({ [k]: 'a' })))
588585

589586
// $ExpectError - this is actually an OrderedMap<number, string>
@@ -929,10 +926,12 @@ personRecordInstance.set('invalid', 25)
929926
personRecordInstance.set('name', '25')
930927
personRecordInstance.set('age', 33)
931928

932-
// $ExpectError
933-
set(personRecordInstance, 'invalid', 25)
934-
set(personRecordInstance, 'name', '25')
935-
set(personRecordInstance, 'age', 33)
929+
// FixMe: The first should be ExpectError, and the second two should be correct,
930+
// however all three produce a hard to understand error because there is a bug
931+
// with Flow's $Call utility type.
932+
// set(personRecordInstance, 'invalid', 25)
933+
// set(personRecordInstance, 'name', '25')
934+
// set(personRecordInstance, 'age', 33)
936935

937936
// Create a Map from a non-prototype "plain" Object
938937
let someObj = Object.create(null);

‎type-definitions/tests/merge.js

Copy file name to clipboardExpand all lines: type-definitions/tests/merge.js
+21-21Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,27 @@ import {
2929
updateIn,
3030
} from '../../';
3131

32+
// merge: Objects as Maps
33+
34+
type ObjMap<T> = { [key: string]: T };
35+
const objMap: ObjMap<number> = { x: 12, y: 34 };
36+
(merge(objMap, { x: 321 }): ObjMap<number>);
37+
(merge(objMap, { z: 321 }): ObjMap<number>);
38+
// $ExpectError
39+
(merge(objMap, { x: 'abc' }): ObjMap<number>);
40+
(merge(objMap, [['x', 321]]): ObjMap<number>);
41+
(merge(objMap, [['z', 321]]): ObjMap<number>);
42+
// $ExpectError
43+
(merge(objMap, [['x', 'abc']]): ObjMap<number>);
44+
// $ExpectError
45+
(merge(objMap, [321]): ObjMap<number>);
46+
(merge(objMap, Map({ x: 123 })): ObjMap<number>);
47+
(merge(objMap, Map({ z: 123 })): ObjMap<number>);
48+
(merge(objMap, Map([['x', 123]])): ObjMap<number>);
49+
(merge(objMap, Map([['z', 123]])): ObjMap<number>);
50+
// $ExpectError
51+
(merge(objMap, List([123])): ObjMap<number>);
52+
3253
// merge: Records
3354

3455
type XYPoint = { x: number, y: number };
@@ -119,27 +140,6 @@ const objRecord: XYPoint = { x: 12, y: 34 };
119140
// $ExpectError
120141
(merge(objRecord, List([123])): XYPoint);
121142

122-
// merge: Objects as Maps
123-
124-
type ObjMap<T> = { [key: string]: T };
125-
const objMap: ObjMap<number> = { x: 12, y: 34 };
126-
(merge(objMap, { x: 321 }): ObjMap<number>);
127-
(merge(objMap, { z: 321 }): ObjMap<number>);
128-
// $ExpectError
129-
(merge(objMap, { x: 'abc' }): ObjMap<number>);
130-
(merge(objMap, [['x', 321]]): ObjMap<number>);
131-
(merge(objMap, [['z', 321]]): ObjMap<number>);
132-
// $ExpectError
133-
(merge(objMap, [['x', 'abc']]): ObjMap<number>);
134-
// $ExpectError
135-
(merge(objMap, [321]): ObjMap<number>);
136-
(merge(objMap, Map({x: 123})): ObjMap<number>);
137-
(merge(objMap, Map({z: 123})): ObjMap<number>);
138-
(merge(objMap, Map([['x', 123]])): ObjMap<number>);
139-
(merge(objMap, Map([['z', 123]])): ObjMap<number>);
140-
// $ExpectError
141-
(merge(objMap, List([123])): ObjMap<number>);
142-
143143
// merge: Arrays
144144

145145
const arr = [ 1, 2, 3 ];

‎type-definitions/tests/record.js

Copy file name to clipboardExpand all lines: type-definitions/tests/record.js
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@ const originAlt1: MakePointNew = MakePointNew();
101101
// Can also sort of use the inner Record values type as an alternative,
102102
// however it does not have the immutable record API, though useful for flowing
103103
// immutable Records where plain objects are expected.
104-
const originAlt2: TPointNew = MakePointNew();
104+
// Remember that Records are *read only*, and using the $ReadOnly helper type
105+
// can ensure correct types.
106+
const originAlt2: $ReadOnly<TPointNew> = MakePointNew();
105107
// $ExpectError cannot use Record API for this alternative annotation
106108
{ const x: number = originAlt2.get('x') }
107109
{ const x: number = originAlt2.x }
@@ -124,7 +126,8 @@ const mistakeNewInstance = new MakePointNew({x: 'string'});
124126

125127
// Subclassing
126128

127-
type TPerson = {name: string, age: number};
129+
// Note use of + for Read Only.
130+
type TPerson = {+name: string, +age: number};
128131
const defaultValues: TPerson = {name: 'Aristotle', age: 2400};
129132
const PersonRecord = Record(defaultValues);
130133

‎yarn.lock

Copy file name to clipboardExpand all lines: yarn.lock
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2540,9 +2540,9 @@ flat-cache@^1.2.1:
25402540
graceful-fs "^4.1.2"
25412541
write "^0.2.1"
25422542

2543-
flow-bin@0.56.0:
2544-
version "0.56.0"
2545-
resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.56.0.tgz#ce43092203a344ba9bf63c0cabe95d95145f6cad"
2543+
flow-bin@0.81.0:
2544+
version "0.81.0"
2545+
resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.81.0.tgz#7f0a733dce1dad3cb1447c692639292dc3d60bf5"
25462546

25472547
follow-redirects@^1.2.5:
25482548
version "1.4.1"

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.