HoriSun / closure-compiler

Automatically exported from code.google.com/p/closure-compiler
0 stars 0 forks source link

Patch for /contrib/externs/w3c_midi.js #1301

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Added the MIDIAccessPromise interface which is the data type returned from 
navigator.requestMIDIAccess()

Original issue reported on code.google.com by RetroModular on 11 Apr 2014 at 9:27

Attachments:

GoogleCodeExporter commented 9 years ago
It looks like this interface has already been removed in Chrome beta, so we 
should probably just annotate requestMIDIAccess as:

@return {!Promise.<MIDIAccess>}

Original comment by tbreisac...@google.com on 12 Apr 2014 at 12:04

GoogleCodeExporter commented 9 years ago
Or I should say, I'm not sure if the interface is removed, but it looks like 
what you get is just a Promise so there is no need for the compiler to know 
about another type.

Original comment by tbreisac...@google.com on 12 Apr 2014 at 12:06

GoogleCodeExporter commented 9 years ago
Yep, you are correct. I was looking at Chrome 34 instead of Chrome 36, the 
latter does indeed use a Promise.

In that case, how would the callbacks for "success" and "failure" be annotated 
correctly - would it not be better to keep MIDIAccessPromise for the externs 
and declare the interface as extending Promise?

Closure might need to be tweaked to handle annotated Promise callbacks unless 
I'm overlooking something here :)

Original comment by RetroModular on 12 Apr 2014 at 12:46

GoogleCodeExporter commented 9 years ago
If you write {!Promise.<!MIDIAccess>} then the compiler should infer that the 
success callback is a function that takes a MIDIAccess. The failure case, it 
won't know, and I'm not sure if we have a good solution for that.

Original comment by tbreisac...@google.com on 12 Apr 2014 at 12:51

GoogleCodeExporter commented 9 years ago
Issue tracking has been migrated to github. Please make any further comments on 
this issue through https://github.com/google/closure-compiler/issues

Original comment by blic...@google.com on 1 May 2014 at 6:31

GoogleCodeExporter commented 9 years ago

Original comment by blic...@google.com on 1 May 2014 at 6:34