-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
chore(ts): api.jsx to api.tsx #14148
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
Conversation
src/sentry/static/sentry/app/utils/requestError/requestError.tsx
Outdated
Show resolved
Hide resolved
a6d8429
to
85e12c0
Compare
src/sentry/static/sentry/app/api.tsx
Outdated
@@ -296,7 +359,7 @@ export class Client { | |||
success: (data, ...args) => { | |||
includeAllArgs ? resolve([data, ...args]) : resolve(data); |
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.
There may be a bug for when includeAllArgs
is true
here. 🤔
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'd love to see all the arguments being forwarded by default. Having to remember to set includeAllArgs
and also unpack an array to get at the xhr object is more tedious than it needs to be.
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.
yeah -- we'd have to update the requestPromise
calls to always expect an array
@@ -96,6 +143,7 @@ export class Client { | |||
if (req && req.alive) { | |||
// Check if API response is a 302 -- means project slug was renamed and user | |||
// needs to be redirected | |||
// @ts-ignore | |||
if (this.hasProjectBeenRenamed(...args)) { | |||
return; |
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.
this.hasProjectBeenRenamed()
expects JQueryXHR
as the input; but this cannot be guaranteed.
Introduced in #8799
44ca1ab
to
611cafe
Compare
}; | ||
|
||
type QueryArgs = | ||
| { |
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.
Should there be a leading |
here?
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 tried to remove it; but prettier seems to be adding this leading |
.
src/sentry/static/sentry/app/api.tsx
Outdated
@@ -296,7 +359,7 @@ export class Client { | |||
success: (data, ...args) => { | |||
includeAllArgs ? resolve([data, ...args]) : resolve(data); |
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'd love to see all the arguments being forwarded by default. Having to remember to set includeAllArgs
and also unpack an array to get at the xhr object is more tedious than it needs to be.
7867c8f
to
742abeb
Compare
type RequestCallbacks = { | ||
success?: (data: any, textStatus?: string, xhr?: JQueryXHR) => void; | ||
complete?: (jqXHR: JQueryXHR, textStatus: string) => void; | ||
error?: FunctionCallback; |
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'm unable to type this properly based on its usage from this file alone. So I'm leaving it as FunctionCallback
.
When Sentry is significantly migrated to TS, we can revisit and refine this type.
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.
Should we be marking things like this somehow?
IncludeAllArgsType extends true | ||
? [any, string | undefined, JQueryXHR | undefined] | ||
: any | ||
> { |
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.
@markstory I'm able to add a conditional type so that the right promise type is returned depending on if includeAllArgs
is true
.
865c659
to
351ed3e
Compare
@dashed is this ready for a final review? |
@billyvg not really no. I'm going to take a few more passes on it and then squash my commits. |
0636923
to
b53ae0a
Compare
Looks like travis-ci is happy with this one now. @billyvg this PR should be ready to go with the mocks typed. |
918da0b
to
4ce9039
Compare
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.
🚢
ee2656e
to
7ed19f9
Compare
7ecf76c
to
09128c5
Compare
NOTES
this.hasProjectBeenRenamed()
error
callback.TODO