From 9f24f0516793b52021c4e9d5152f131c6f30afa9 Mon Sep 17 00:00:00 2001 From: Pascal Hartig Date: Tue, 16 Oct 2018 03:05:53 -0700 Subject: [PATCH] Best effort of extending immutable declaration Summary: It's still very much incomplete but this now exports some of the top-level functions I'm about to use. I'd love to just import https://github.com/facebook/immutable-js/blob/f71ccd5db2016e0dbed72838ab81b931b5e90e9e/type-definitions/immutable.js.flow but this doesn't actually work as a module declaration because top-level type declarations are incompatible with it at the moment ... sigh. Reviewed By: danielbuechele Differential Revision: D10378353 fbshipit-source-id: 3023882b8bd38cf25d9a6c97905ff71548105775 --- flow-typed/npm/immutable_v4.x.x.js | 51 +++++++++++------------------- 1 file changed, 18 insertions(+), 33 deletions(-) diff --git a/flow-typed/npm/immutable_v4.x.x.js b/flow-typed/npm/immutable_v4.x.x.js index 2ecc9f922..b7d1b0ee6 100644 --- a/flow-typed/npm/immutable_v4.x.x.js +++ b/flow-typed/npm/immutable_v4.x.x.js @@ -21,6 +21,10 @@ * @flow */ +// Helper type that represents plain objects allowed as arguments to +// some constructors and functions. +type PlainObjInput = {+[key: K]: V, __proto__: null}; + declare module 'immutable' { /** * This file provides type definitions for use with the Flow type checker. @@ -1227,37 +1231,18 @@ declare module 'immutable' { declare function is(first: mixed, second: mixed): boolean; declare function hash(value: mixed): number; -} -/** - * BSD License - * - * For Immutable JS software - * - * Copyright (c) 2014-2015, Facebook, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * * Neither the name Facebook nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ \ No newline at end of file + declare function merge( + collection: C, + ...collections: Array | PlainObjInput> + ): C; + declare function mergeDeep( + collection: C, + ...collections: Array | PlainObjInput> + ): C; + declare function mergeDeepWith( + merger: (oldVal: any, newVal: any, key: any) => mixed, + collection: C, + ...collections: Array | PlainObjInput> + ): C; +} \ No newline at end of file