Skip to content

Instantly share code, notes, and snippets.

@mikeauclair
Created January 4, 2017 22:36
Show Gist options
  • Save mikeauclair/ee083ef1fac277b82f17691247496522 to your computer and use it in GitHub Desktop.
Save mikeauclair/ee083ef1fac277b82f17691247496522 to your computer and use it in GitHub Desktop.
Promise union type
± ./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
/* @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