fix: augment FetchError type to include IFetchError#279
Conversation
Member
|
Thanks for this PR dear @johannschopplich but splitting the types out of the class was intentional. (sadly) esbuild adds them as public accessors which makes them (wrongly) visible on stack traces while they should be getters only.. I am thinking if possible to sole type issue somehow differently while keeping runtime minimal. |
Contributor
Author
|
Oh, I see! I wasn't aware of that issue. Maybe there's another way of merging the types then. 🤔 |
FetchError type to include IFetchError
Contributor
Author
|
Edit: I have updated this PR to use a type-only approach: We can augment // Augment `FetchError` type to include `IFetchError` properties
export interface FetchError<T = any> extends IFetchError<T> {} |
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
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.
🔗 Linked issue
#278
❓ Type of change
📚 Description
With the latest ofetch version, the
FetchErrordoes implement theIFetchErrorinterface, but TS won't provide the types. Thus, onlymessage,stacketc. properties are available.Since the
FetchErrorwill be initiated bycreateFetchError, we can add the properties from the interface directly in the class definition, without the need of setting them in the constructor. With these changes, TypeScript understands.📝 Checklist