Created
January 4, 2017 22:36
-
-
Save mikeauclair/ee083ef1fac277b82f17691247496522 to your computer and use it in GitHub Desktop.
Promise union type
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
± ./node_modules/.bin/flow check 039efe8|add_more_types* | |
test.js:18 | |
18: getQQ().then(function(val){ | |
^^^^ property `then`. Property not found in | |
18: getQQ().then(function(val){ | |
^^^^^^^ Array | |
Found 1 error |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* @flow */ | |
type QQ = number[]; | |
type QQOrDeferred = Promise<QQ> | QQ; | |
function remoteQQ(): Promise<QQ>{ | |
return Promise.resolve([35]); | |
} | |
function getQQ(preloaded?: QQ): QQOrDeferred { | |
if (preloaded) { | |
return preloaded; | |
} else { | |
return remoteQQ(); | |
} | |
} | |
getQQ().then(function(val){ | |
console.log(val); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment