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

Adds types to FetchService #45

Merged
merged 13 commits into from
Mar 22, 2023
Merged

Adds types to FetchService #45

merged 13 commits into from
Mar 22, 2023

Conversation

jeffdaley
Copy link
Contributor

@jeffdaley jeffdaley commented Feb 10, 2023

Adds types to the FetchService

@jeffdaley jeffdaley marked this pull request as draft February 10, 2023 18:28
@jeffdaley jeffdaley marked this pull request as ready for review February 10, 2023 18:39
@jeffdaley jeffdaley requested a review from a team as a code owner February 11, 2023 00:03
@@ -93,7 +93,10 @@ export default class DraftsRoute extends Route {
"/api/v1/drafts?" +
this.createDraftURLSearchParams(params, ownerFacetOnly)
)
.then((response) => response.json());
.then((response) => {
assert("response must be defined", response);
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm curious about the uses of assert in this PR because assertions are removed for production builds - can you explain the intent behind these?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To pass type checking and hopefully to pinpoint errors better in development. resp can be undefined so we have to assert it or invoke it with a question mark resp?.json(). I expect a response so I opted to assert 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.

Thinking about this a little more. I see where you're coming from. It's both more succinct and more true to use the resp?.json() invocation. Any benefit of assertion-error proximity is minimal. I'm going to change the approach!

@jeffdaley jeffdaley marked this pull request as draft March 8, 2023 01:40
@jeffdaley jeffdaley marked this pull request as ready for review March 20, 2023 15:04
@jeffdaley jeffdaley merged commit 2399c1e into main Mar 22, 2023
@jeffdaley jeffdaley deleted the jeffdaley/type-fetch-service branch March 22, 2023 23:54
anuragprafulla referenced this pull request in razorpay/hermes Jun 27, 2023
* Adds types to FetchService

* Update maybeUndefined

* Add fetch to tsconfig

* Fix type errors

* Update people-select.ts

* Remove unnecessary import
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.

None yet

2 participants