html-externs
html-externs copied to clipboard
Use new function type syntax
It would be great if we could support the new function type since this would provide richer completion/documentation for the working with JavaScript. I noticed this information is already available in the webidls.
For example; BaseAudioContext webidl:
callback DecodeSuccessCallback = void (AudioBuffer decodedData);
callback DecodeErrorCallback = void (DOMException error);
...
Promise<AudioBuffer> decodeAudioData(ArrayBuffer audioData,
optional DecodeSuccessCallback successCallback,
optional DecodeErrorCallback errorCallback);
Currently we generate:
function decodeAudioData(audioData:js.lib.ArrayBuffer, ?successCallback:AudioBuffer->Void, ?errorCallback:js.html.DOMException->Void):Promise<AudioBuffer>;
This could be improved like this:
function decodeAudioData(audioData:js.lib.ArrayBuffer, ?successCallback:(decodedData:AudioBuffer) -> Void,
?errorCallback:(error:DOMException) -> Void):Promise<AudioBuffer>;
.. or with typedef
function decodeAudioData(audioData:js.lib.ArrayBuffer, ?successCallback:DecodeSuccessCallback, ?errorCallback:DecodeErrorCallback):Promise<AudioBuffer>;
typedef DecodeSuccessCallback = (decodedData:AudioBuffer) -> Void;
typedef DecodeErrorCallback = (error:DOMException) -> Void;
If the info is not available we can always fallback to the "old syntax".