-
Notifications
You must be signed in to change notification settings - Fork 201
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
Proper TS types #117
Proper TS types #117
Conversation
@developit friendly 🏓 |
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 looks good to me, but I wonder if it'll cause folks trouble because the types are now different for unfetch
VS isomorphic-unfetch
? You'd know better than I, I'm not much of a TS user.
Well, depends on how you look at it. It won't cause people much trouble because one is probably not using both in the same project, but I don't know how to properly support types from this PR when using So landing this would definitely make both of those packages providing different typings, but at least for browser-only unfetch users they would be correct and would save users from using it like a regular, full-blown |
Makes sense. Anyone using |
Yes - thats my understanding. Isomorphic-fetch wont even know about those typings here because they are not referenced anyhow from there |
@@ -12,6 +12,33 @@ declare namespace unfetch { | |||
export type IsomorphicRequest = Request | NodeRequest | |||
} | |||
|
|||
declare const unfetch: typeof fetch; | |||
type UnfetchResponse = { |
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.
Wouldn't it be better if we export this type so that TS developers could use it in their code?
} | ||
} | ||
|
||
type Unfetch = ( |
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.
Same
@developit friendly 🏓 |
Specifying unfetch type as the same as fetch is a stretch - so I've written down better, more accurate types.