| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
There was a problem hiding this comment.
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.
Sorry, something went wrong.
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 isomorphic-unfetch. I'm not aware of any way to make TS resolve types based on target environment or anything like that - it always resolves node_modules to "main". 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 fetch. |
Sorry, something went wrong.
|
Makes sense. Anyone using isomorphic-unfetch is unaffected by this change then, they'll still get the (incorrect, but uniform) types from node-fetch? |
Sorry, something went wrong.
|
Yes - thats my understanding. Isomorphic-fetch wont even know about those typings here because they are not referenced anyhow from there |
Sorry, something went wrong.
| } | ||
|
|
||
| declare const unfetch: typeof fetch; | ||
| type UnfetchResponse = { |
There was a problem hiding this comment.
Wouldn't it be better if we export this type so that TS developers could use it in their code?
Sorry, something went wrong.
| } | ||
| } | ||
|
|
||
| type Unfetch = ( |
There was a problem hiding this comment.
Same
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Specifying unfetch type as the same as fetch is a stretch - so I've written down better, more accurate types.