-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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
Update gapi.load typing. #18762
Conversation
types/gapi/index.d.ts to author (@sgtfrankieboy). Could you review this PR? Checklist
|
8eec341
to
40d1b32
Compare
types/gapi/index.d.ts
Outdated
@@ -35,10 +35,20 @@ interface GoogleApiOAuth2TokenObject { | |||
*/ | |||
declare namespace gapi { | |||
|
|||
type LoadCallback = () => void | Function; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
.
40d1b32
to
25da038
Compare
types/gapi/index.d.ts
Outdated
@@ -35,10 +35,20 @@ interface GoogleApiOAuth2TokenObject { | |||
*/ | |||
declare namespace gapi { | |||
|
|||
type LoadCallback = () => void | Function; |
There was a problem hiding this comment.
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.
25da038
to
fc5dbb2
Compare
types/gapi/index.d.ts
Outdated
@@ -35,10 +35,20 @@ interface GoogleApiOAuth2TokenObject { | |||
*/ | |||
declare namespace gapi { | |||
|
|||
type LoadCallback = () => void | ((...args: any[]) => void); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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;
fc5dbb2
to
8c7aaba
Compare
Please fill in this template.
npm run lint package-name
(ortsc
if notslint.json
is present).If changing an existing definition:
tslint.json
containing{ "extends": "dtslint/dt.json" }
.