Skip to content
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

Abuse typescript generics to show the error message for calls to die #669

Closed
wants to merge 1 commit into from

Conversation

forivall
Copy link

doc: add generic to die to show what the error number means

Mostly, I did this to help me understand the error codes quicker as i'm looking through how immer works.

Screen Shot 2020-09-11 at 4 01 45 PM
Screen Shot 2020-09-11 at 4 02 42 PM

Feel free to close if you don't want this in your codebase.

@codesandbox-ci
Copy link

codesandbox-ci bot commented Sep 11, 2020

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 1acba46:

Sandbox Source
Immer sandbox Configuration

@@ -1,8 +1,9 @@
type S = string & {}
Copy link
Author

Choose a reason for hiding this comment

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

In ts < 4, this prevents the const string literal from merging with the string type. can be removed to just "string" in ts 4.0+

@mweststrate
Copy link
Collaborator

Closing as this makes the die definition itself now quite hard to read for just a few call sites :). I think a much simpler solution would be to add a JSDoc comment above those functions? Nonetheless thanks for sharing

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.

None yet

2 participants