function testMap() { RSVP.map([RSVP.resolve(1), RSVP.resolve(2)], item => item + 1, 'add one').then(results => { assertType<number[]>(results); assertType<{ length: 2 }>(results); }); RSVP.map([RSVP.resolve('a string'), RSVP.resolve(112233)], String).then(results => { assertType<string[]>(results); assertType<{ length: 2 }>(results); }); // This is the best we can do: we can't actually write the full type here, // which would be `assertType<never>(results)`, but TS can't infer that. RSVP.map([RSVP.reject('for any reason')], String).then(results => { assertType<{}>(results); }); }
RSVP.hash(promiseHash).then( values => { return ( values.promiseA < 0 && values.promiseB === 4 && values.promiseC === 12 && values.notAPromise > 0 ); }, err => {} ); let mapFn = function(item: number) { return item + 1; }; RSVP.map(promiseArray, mapFn).then(function(result) {}); let promise = new Promise(function(resolve, reject) { resolve(); reject(); }); promise.then(value => {}, reason => {}); function throws() { throw new Error('Whoops!'); } let throwingPromise = new RSVP.Promise(function(resolve, reject) { throws(); }); throwingPromise.catch(RSVP.rethrow).then(value => {}, reason => {});