Assert values of enum datasets and other tweaks#1743
Merged
Conversation
axelboc
commented
Jan 27, 2025
| if (isComplexType(type)) { | ||
| return createMatrixComplexFormatter(notation); | ||
| } | ||
| ): (val: ScalarValue<PrintableType>) => string; // override distributivity of `ValueFormatter` |
Contributor
Author
There was a problem hiding this comment.
ValueFormatter is now distributive: ValueFormatter<PrintableType> is now (val: string) => string | (val: number) => string | (val: number | boolean) => string | ... instead of (val: string | number | boolean | ...) => string.
This simplifies typing the formatter factories, like createNumericFormatter, formatBool, etc. and saves us from using the as keyword in a few places.
However, the consumers of getFormatter don't like this new distributive type; when the time comes to call it, the val parameter is inferred to never (because there's no possible intersection type). So I'm overriding the return value to remove the distributivity and get back to (val: string | number | boolean | ...) => string.
loichuder
approved these changes
Jan 31, 2025
| if (isComplexType(type)) { | ||
| return createMatrixComplexFormatter(notation); | ||
| } | ||
| ): (val: ScalarValue<PrintableType>) => string; // override distributivity of `ValueFormatter` |
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.
A final mixed bag of changes ahead of supporting bigints (cf. list of commits).