diff --git a/type-definitions/immutable.d.ts b/type-definitions/immutable.d.ts index 38ecac080a..ead7f225f9 100644 --- a/type-definitions/immutable.d.ts +++ b/type-definitions/immutable.d.ts @@ -5161,18 +5161,18 @@ declare namespace Immutable { * [3]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_iterable_protocol * "The iterable protocol" */ + function fromJS( + jsValue: JSValue, + reviver?: undefined + ): FromJS; function fromJS( jsValue: unknown, - reviver: ( + reviver?: ( key: string | number, sequence: Collection.Keyed | Collection.Indexed, path?: Array ) => unknown ): Collection; - function fromJS( - jsValue: JSValue, - reviver?: undefined - ): FromJS; type FromJS = JSValue extends FromJSNoTransform ? JSValue diff --git a/type-definitions/ts-tests/from-js.ts b/type-definitions/ts-tests/from-js.ts index 98191dcd0a..83220e512a 100644 --- a/type-definitions/ts-tests/from-js.ts +++ b/type-definitions/ts-tests/from-js.ts @@ -33,3 +33,17 @@ import { fromJS, List, Map } from 'immutable'; // $ExpectType Map<"a", Map<"b", Map<"c", number>>> fromJS({a: {b: {c: 0}}}); } + +{ + // fromJS in an array of function + + const create = [(data: any) => data, fromJS][1]; + + // $ExpectType any + create({ a: 'A' }); + + const createConst = ([(data: any) => data, fromJS] as const)[1]; + + // $ExpectType Map<"a", string> + createConst({ a: 'A' }); +}