Skip to content

Commit

Permalink
Clean .flowconfig so users won't need configuration to use fbjs (#182)
Browse files Browse the repository at this point in the history
* Update to Flow v0.32.0

* Get rid of Flow suppress_type

* Get rid of flow lib by inlining Promise.prototype.done polyfill

* Get rid of unused include

* Get rid of unused ignore

(cherry picked from commit 4113922)
  • Loading branch information
gabelevi authored and zpao committed Sep 27, 2016
1 parent e13bb57 commit d822b44
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 60 deletions.
40 changes: 0 additions & 40 deletions flow/lib/Promise.js

This file was deleted.

10 changes: 0 additions & 10 deletions flow/lib/dev.js

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 1 addition & 7 deletions src/.flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 10 additions & 1 deletion src/core/Deferred.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,16 @@ class Deferred<Tvalue, Treason> {
}

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 {
Expand Down
3 changes: 2 additions & 1 deletion src/core/shallowEqual.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit d822b44

Please sign in to comment.