Skip to content

Commit a1029bb

Browse files
committed
Include flow types for Record.get() mirroring immutable-js#1461
1 parent 7ea2223 commit a1029bb

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

type-definitions/immutable.js.flow

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1401,7 +1401,9 @@ declare class RecordInstance<T: Object> {
14011401
size: number;
14021402

14031403
has(key: string): boolean;
1404-
get<K: $Keys<T>>(key: K, notSetValue: mixed): $ElementType<T, K>;
1404+
1405+
get<K: $Keys<T>>(key: K, ..._: []): $ElementType<T, K>;
1406+
get<K: $Keys<T>, NSV>(key: K, notSetValue: NSV): $ElementType<T, K> | NSV;
14051407

14061408
hasIn(keyPath: Iterable<mixed>): boolean;
14071409

type-definitions/tests/record.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ let geoPointExpected2: RecordOf<TGeoPoint> = Point2({});
4141
const px = origin2.get('x');
4242
const px2: number = origin2.x;
4343
// $ExpectError
44+
const px3: number = origin2.get('x', 'not set value');
45+
const px4: number | string = origin2.get('x', 'not set value');
46+
// $ExpectError
4447
const pz = origin2.get('z');
4548
// $ExpectError
4649
const pz2 = origin2.z;

0 commit comments

Comments
 (0)