Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update gapi.load typing. #18762

Merged
merged 1 commit into from
Aug 14, 2017
Merged

Conversation

trshafer
Copy link
Contributor

@trshafer trshafer commented Aug 8, 2017

Please fill in this template.

  • Use a meaningful title for the pull request. Include the name of the package modified.
  • Test the change in your own code. (Compile and run.)
  • Follow the advice from the readme.
  • Avoid common mistakes.
  • Run npm run lint package-name (or tsc if no tslint.json is present).

If changing an existing definition:

@dt-bot
Copy link
Member

dt-bot commented Aug 8, 2017

types/gapi/index.d.ts

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

Checklist

  • pass the Travis CI test?

@@ -35,10 +35,20 @@ interface GoogleApiOAuth2TokenObject {
*/
declare namespace gapi {

type LoadCallback = () => void | Function;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I know this is kind of a weird declaration, () => void is technically correct. However many consumers use something like:

new Promise((resolve) => {
  gapi.load('thing', resolve)
})

and resolve does not have the type of () => void, so I added Function as a blanket catchall.

Copy link
Contributor

Choose a reason for hiding this comment

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

If this is a callback, then (...args:any[]) => void should be your fallback. or just use Function. the union does not make much sense, since Function subsumes it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Removed Function and changed the fallback to (...args: any[]) => void.

@@ -35,10 +35,20 @@ interface GoogleApiOAuth2TokenObject {
*/
declare namespace gapi {

type LoadCallback = () => void | Function;
Copy link
Contributor

Choose a reason for hiding this comment

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

If this is a callback, then (...args:any[]) => void should be your fallback. or just use Function. the union does not make much sense, since Function subsumes it.

@mhegazy mhegazy added the Revision needed This PR needs code changes before it can be merged. label Aug 14, 2017
@@ -35,10 +35,20 @@ interface GoogleApiOAuth2TokenObject {
*/
declare namespace gapi {

type LoadCallback = () => void | ((...args: any[]) => void);
Copy link
Contributor

Choose a reason for hiding this comment

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

you do not need ()=>void

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. the load callback is now only (...args: any[]) => void;

@mhegazy mhegazy merged commit 270913d into DefinitelyTyped:master Aug 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Revision needed This PR needs code changes before it can be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants