Skip to content

Allow dictionaries and callbacks to be distinguishable #1191

Closed
@jakearchibald

Description

@jakearchibald

https://webidl.spec.whatwg.org/#dfn-distinguishable

It isn't clear to me why callbacks and dictionaries can't be distinguished.

I'm designing an API like:

whatever(callback);

But there's a strong possibility that options will be added in future, and I want to avoid this pattern:

whatever(() => {
  // Quite
  // a
  // bit
  // of
  // code
}, { behaveDifferently: true });

And instead go for:

whatever({
  behaveDifferently: true,
  callback() {
    // Quite
    // a
    // bit
    // of
    // code
  }
});

But it seems like I can't overload from whatever(callback) to whatever({ callback }).

I would have assumed that an argument could be treated as a callback if it's callable.

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