FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Proper TS types by Andarist · Pull Request #117 · developit/unfetch · GitHub

Repository navigation

Proper TS types - #117

Merged
developit merged 4 commits into
developit:masterfrom
Andarist:better-types
Sep 29, 2020
Merged

developit merged 4 commits into
developit:masterfrom
Andarist:better-types

Conversation

Copy link
Copy Markdown
Contributor

Specifying unfetch type as the same as fetch is a stretch - so I've written down better, more accurate types.

Andarist commented Dec 3, 2019

Copy link
Copy Markdown
Contributor Author

@developit friendly 🏓

developit left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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.

Copy link
Copy Markdown
Contributor Author

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?

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.

Copy link
Copy Markdown
Owner

Makes sense. Anyone using isomorphic-unfetch is unaffected by this change then, they'll still get the (incorrect, but uniform) types from node-fetch?

Copy link
Copy Markdown
Contributor Author

Yes - thats my understanding. Isomorphic-fetch wont even know about those typings here because they are not referenced anyhow from there

Comment thread src/index.d.ts
}

declare const unfetch: typeof fetch;
type UnfetchResponse = {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Wouldn't it be better if we export this type so that TS developers could use it in their code?

Comment thread src/index.d.ts
}
}

type Unfetch = (

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Same

Andarist commented Aug 6, 2020

Copy link
Copy Markdown
Contributor Author

@developit friendly 🏓

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

3 participants


Back | FazBrowse Home | New Git URL