Skip to content

Use new function type syntax #18

@markknol

Description

@markknol

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".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions