This repository has been archived by the owner on Apr 4, 2022. It is now read-only.
Add TypeScript types to fetchFunc option #1098
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds more specific TypeScript types to the
fetchFunc
option.Using
Function
is the same as(...args: any) => any
, meaning that any function would be accepted as a validfetchFunc
. With this PR, the supplied function will need to conform to the minimalfetch
interface. Essentially, functions will need to have the following properties:Most of this should be easily achievable with
XMLHttpRequest
, and even easier if you can reuse the browser'sHeaders
class.I'm fairly confident this also covers all our usage in
kinto.js
, but if not I'll update the types here to ensure that responses fromkinto-http.js
have all the bits thatkinto.js
wants.(Also, since the new
fetchFunc
option is for Firefox, these types won't be enforced. They will, however, be a good guide to follow when building since they represent all the functionality thatkinto-http.js
expects fromfetch
.)