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

On August 14, 2014 at 7:31:05 PM, Jonas Sicking (jonas@sicking.cc) wrote:
> On Thu, Aug 14, 2014 at 1:36 PM, Marcos Caceres wrote:
> > interface ScreenOrientation {
> > Promise lock (OrientationLockType orientation);
> > }
>  
> It doesn't make sense to put a *value* between the <>. You should put
> a *type* there. I.e. it doesn't make sense to do
>  
> Promise<1> returnOne();
>  
> The thing you do is
>  
> Promise returnOne();
>  
> 'void' is the type for 'nothing', so that's what should be used for
> functions that only return undefined. Whether they return that
> synchronously or asynchronously.

Yeah, agree. The confusion was "undefined" being treated as a type (not at a value).  

Received on Thursday, 14 August 2014 23:33:35 UTC