-
Notifications
You must be signed in to change notification settings - Fork 17
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
Truncate long types #32
Conversation
Perhaps this behavior ought to be toggleable with a flag? |
@@ -30,14 +30,18 @@ const getValidationContext = (validation: t.ValidationError) => | |||
// https://github.com/gcanti/fp-ts/pull/544/files | |||
validation.context as t.ContextEntry[]; | |||
|
|||
export const TYPE_MAX_LEN = 160; // Two lines of 80-col text | |||
const truncateType = (type: string): string => | |||
type.length > TYPE_MAX_LEN ? `${type.slice(0, TYPE_MAX_LEN - 3)}...` : type; |
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.
An alternative is to do the ...
in the middle and show both the beginning and end, to make it feel more "complete"
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.
Yeah, it would look better.
@@ -30,14 +30,18 @@ const getValidationContext = (validation: t.ValidationError) => | |||
// https://github.com/gcanti/fp-ts/pull/544/files | |||
validation.context as t.ContextEntry[]; | |||
|
|||
export const TYPE_MAX_LEN = 160; // Two lines of 80-col text |
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 is an arbitrary number, perhaps it can be an overridable default
Can generally be smarter of how to do truncation like TypeScript is - but didn't implement that here. a lightly modified example of an error while developing:
|
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.
Looks good!
@osdiab Sorry, I merged a PR before yours and there are conflicts now 🤦 Once you fix them I'll merge and release |
…into osdiab/truncate
fixed! |
Not sure what the version should be in the |
Solved #32 (comment) |
Released v1.2.1. Thanks! |
Seems like this is a breaking change shipped in a patch release. At least a lot of tests in my projects are failing due to this new default behavior. I’ll try to make a PR in the next days to provide an option to disable this behavior. |
You are totally right, it should've been a major. Sorry for the inconvenience 😬 |
Super long types in my app are pretty hard to read, this cuts them to 160 chars max.
Closes #2