Skip to content

Change order of overloads so that user code doesn't need parameter type declarations.#12389

Merged
1 commit merged into
types-2.0from
overloads
Nov 1, 2016
Merged

Change order of overloads so that user code doesn't need parameter type declarations.#12389
1 commit merged into
types-2.0from
overloads

Conversation

@ghost
Copy link
Copy Markdown

@ghost ghost commented Oct 31, 2016

Undoes the changes in #12344 and changes the order of overload declarations instead.
Does not undo the change to zepto-tests.ts since that would genuinely be an implicit any.

@dt-bot
Copy link
Copy Markdown
Member

dt-bot commented Oct 31, 2016

angular/index.d.ts

to author (@diegovilar). Could you review this PR?
👍 or 👎?

Checklist

  • pass the Travis CI test?

d3-array/index.d.ts

to authors (@gustavderdrache @borisyankov @tomwanzek). Could you review this PR?
👍 or 👎?

Checklist

  • pass the Travis CI test?

flickity/index.d.ts

to author (Chris McGrath (account can't be detected)). Could you review this PR?
👍 or 👎?

Checklist

  • pass the Travis CI test?

fromjs/index.d.ts

to author (@glenndierckx). Could you review this PR?
👍 or 👎?

Checklist

  • pass the Travis CI test?

jasmine/index.d.ts

to authors (@borisyankov @theodorejb @davidparsson). Could you review this PR?
👍 or 👎?

Checklist

  • pass the Travis CI test?

mongoose-promise/index.d.ts

to author (@simonxca). Could you review this PR?
👍 or 👎?

Checklist

  • pass the Travis CI test?

mongoose/index.d.ts

to authors (@simonxca @horiuchi). Could you review this PR?
👍 or 👎?

Checklist

  • pass the Travis CI test?

multiplexjs/index.d.ts

to author (@KamyarNazeri). Could you review this PR?
👍 or 👎?

Checklist

  • pass the Travis CI test?

nightmare/index.d.ts

to author (@horiuchi). Could you review this PR?
👍 or 👎?

Checklist

  • pass the Travis CI test?

phantom/index.d.ts

to authors (@horiuchi @llRandom). Could you review this PR?
👍 or 👎?

Checklist

  • pass the Travis CI test?

pinkyswear/index.d.ts

to author (@chances). Could you review this PR?
👍 or 👎?

Checklist

  • pass the Travis CI test?

prelude-ls/index.d.ts

to author (@AyaMorisawa). Could you review this PR?
👍 or 👎?

Checklist

  • pass the Travis CI test?

webtorrent/index.d.ts

to author (Bazyli Brzóska (account can't be detected)). Could you review this PR?
👍 or 👎?

Checklist

  • pass the Travis CI test?

yargs/index.d.ts

to authors (@poelstra @mizunashi-mana). Could you review this PR?
👍 or 👎?

Checklist

  • pass the Travis CI test?

@ghost ghost assigned sandersn Oct 31, 2016
Comment thread flickity/index.d.ts
* @param callback callback funtion to execute when event fires
*/
on(eventname: string, callback: (eventt?: Event, cellElement?: Element) => any) : void;
on(eventname: string, callback: (event?: Event, pointer?: Element | Touch, cellElement?: Element, cellIndex?: number) => any): void;
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've just changed the order of these, but these overloads don't really make sense -- they all take a string and a function, so how does the library know what kind of values to pass to the function? Can we use string literal types here? @clmcgrath

Comment thread phantom/index.d.ts
close(): Promise<void>;

evaluate<R>(callback: () => R): Promise<R>;
evaluate<T>(callback: (arg: T) => void, arg: T): Promise<void>;
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is handled by the case following it.

* Adds a listener to the complete (success) event.
* @deprecated Adds a listener to the complete (success) event.
*/
addCallback(listener: (arg: T) => void): this;
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just (...args: T[]) where the length happens to be 1.

Copy link
Copy Markdown
Contributor

@sandersn sandersn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes look technically correct, although you might want to keep some short overloads for documentation. Most people don't know that i =>i is assignable to cb: (item: T, key: TKey) => void, for example, so having redundant overloads can make that clearer.

@ghost
Copy link
Copy Markdown
Author

ghost commented Oct 31, 2016

We don't do that for e.g. forEach; most people will be looking at the intellisense rather than at the declaration file itself, and an overload with fewer parameters will be hidden. So I don't think it helps to have the extra overloads.

@sandersn
Copy link
Copy Markdown
Contributor

It's up to you; VS and VS Code do put multiple overloads behind an up/down arrow interface. But Emacs only shows the first. I don't know what other editors do.

@poelstra
Copy link
Copy Markdown
Contributor

poelstra commented Nov 1, 2016

@Andy-MS 👍 for the yargs changes.

@ghost ghost merged commit e515b24 into types-2.0 Nov 1, 2016
@ghost ghost deleted the overloads branch November 1, 2016 12:45
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants