-
-
Notifications
You must be signed in to change notification settings - Fork 366
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
Use KyRequest and KyResponse types in errors #610
Use KyRequest and KyResponse types in errors #610
Conversation
- introduces `KyRequest` which, like `KyResponse`, adds `json()` convenience method for extracting JSON with an expected TypeScript type - update API `Request`/`Response` usages to expose `KyRequest`/`KyResponse` to `ky` consumers so that they may use the `json()` convenience method in more scenarios (`HTTPError`, `TimeoutError`, and hooks) Refs: sindresorhus#584
LGTM, but another TS user should review, too. Do we have a decent place to document this? Perhaps the readme should mention it. |
That's a good point. The existing |
Yeah, I don't think the documentation about TS needs to be extensive. Autocomplete should be sufficient for most users. But I think it would be good to mention it somewhere, maybe as a feature in the benefits section at the top of the readme. |
@sholladay I took a stab at mentioning these TS improvements in the readme's benefits section. I tried to keep it short like the other bullet points. Suggestions welcome (more words, less, etc.). |
Good enough for me. We can tweak it later if needed. I'm going to merge this now since we have quite a few open PRs and I want to avoid creating unnecessary conflicts by leaving things open. Thanks again! |
KyRequest
which, likeKyResponse
, addsjson()
convenience method for extracting JSON with an expected TypeScript typeRequest
/Response
usages to exposeKyRequest
/KyResponse
toky
consumers so that they may use thejson()
convenience method in more scenarios (HTTPError
,TimeoutError
, and hooks)Closes #584