diff --git a/flow/lib/Promise.js b/flow/lib/Promise.js deleted file mode 100644 index 510e3d5d..00000000 --- a/flow/lib/Promise.js +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Copyright (c) 2013-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ - -// These annotations are copy/pasted from the built-in Flow definitions for -// Native Promises with some non-standard APIs added in -declare class Promise<+R> { - constructor(callback: ( - resolve: (result?: Promise | R) => void, - reject: (error?: any) => void - ) => mixed): void; - - then( - onFulfill?: ?(value: R) => Promise | ?U, - onReject?: ?(error: any) => Promise | ?U - ): Promise; - - catch( - onReject?: (error: any) => ?Promise | U - ): Promise; - - static resolve(object?: Promise | T): Promise; - static reject(error?: any): Promise; - - static all: Promise$All; - static race(promises: Array>): Promise; - - // Non-standard APIs - done( - onFulfill?: ?(value: R) => mixed, - onReject?: ?(error: any) => mixed - ): void; - - static cast(object?: T): Promise; -} diff --git a/flow/lib/dev.js b/flow/lib/dev.js deleted file mode 100644 index 24bedef3..00000000 --- a/flow/lib/dev.js +++ /dev/null @@ -1,10 +0,0 @@ -/** - * Copyright 2013-2015, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ - -declare var __DEV__: boolean; diff --git a/package.json b/package.json index fc3d0156..6f33e16f 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "del": "^2.2.0", "eslint": "^2.8.0", "fbjs-scripts": "file:scripts", - "flow-bin": "^0.25.0", + "flow-bin": "^0.32.0", "gulp": "^3.9.1", "gulp-babel": "^6.1.2", "gulp-flatten": "^0.2.0", diff --git a/src/.flowconfig b/src/.flowconfig index b741dd12..40749cca 100644 --- a/src/.flowconfig +++ b/src/.flowconfig @@ -2,15 +2,9 @@ .*/__tests__/.* [include] -../node_modules/promise - -[libs] -../flow/lib [options] module.system=haste -suppress_type=$FlowIssue - [version] -^0.25.0 +^0.32.0 diff --git a/src/core/Deferred.js b/src/core/Deferred.js index 587a6c4c..4f811407 100644 --- a/src/core/Deferred.js +++ b/src/core/Deferred.js @@ -57,7 +57,16 @@ class Deferred { } done(): void { - Promise.prototype.done.apply(this._promise, arguments); + // Embed the polyfill for the non-standard Promise.prototype.done so that + // users of the open source fbjs don't need a custom lib for Promise + const promise = arguments.length ? + this._promise.then.apply(this._promise, arguments) : + this._promise; + promise.then(undefined, function(err) { + setTimeout(function() { + throw err; + }, 0); + }); } isSettled(): boolean { diff --git a/src/core/shallowEqual.js b/src/core/shallowEqual.js index 87d440bd..2eaa5efc 100644 --- a/src/core/shallowEqual.js +++ b/src/core/shallowEqual.js @@ -25,7 +25,8 @@ function is(x: mixed, y: mixed): boolean { // SameValue algorithm if (x === y) { // Steps 1-5, 7-10 // Steps 6.b-6.e: +0 != -0 - return x !== 0 || 1 / (x: $FlowIssue) === 1 / (y: $FlowIssue); + // Added the nonzero y check to make Flow happy, but it is redundant + return x !== 0 || y !== 0 || 1 / x === 1 / y; } else { // Step 6.a: NaN == NaN return x !== x && y !== y;