RE: Promise<void> or Promise<undefined>?, was Re: RfC: pre-LC version of Screen Orientation; deadline August 18

From: Marcos Caceres <marcos@marcosc.com>

> It was raised elsewhere that maybe this should be `Promise<void>` instead? What would be more idiomatic?

For JS? undefined. For WebIDL? void.

> Using void seems to make more sense then passing `undefined` to the resolver - as the arguments.length would be 0 instead of 1 (undefined).

I don't think it makes any difference. From the engine's perspective, resolve() and resolve(undefined) are indistinguishable. arguments.length of the onFulfilled callback is unaffected:

```js
Promise.resolve(undefined).then(function () {
  assert(arguments.length === 0);
});

Promise.resolve().then(function (value) {
  assert(arguments.length === 1);
});
```

Received on Thursday, 14 August 2014 20:44:49 UTC