Conversation
There was a problem hiding this comment.
Pull Request Overview
A refactor to simplify and consolidate TypeScript utility types for discriminated unions and merged unions, improving type safety and addressing a bug.
- Replaced multiple internal helpers with
UnionKeys,BuildMember, andExpand - Updated
DiscriminatedUnionsignature to include an optionalTagsparameter - Simplified
MergedUnionimplementation and removed legacy merge utilities
Comments suppressed due to low confidence (3)
src/index.ts:36
- The JSDoc template tags (
@template TDiscriminatorand@template TStates) no longer match the updated generic parameters (Discriminator,Variants,Tags). Please update or add@templateannotations to reflectDiscriminator,Variants, and the optionalTagsparameter.
* @template TDiscriminator - The string literal type that will be used as the discriminator property name
src/index.ts:78
- [nitpick] The type parameters
AandBinMergedUnion<A, B>are not very descriptive. Consider renaming them to something likeLeft,RightorTFirst,TSecondto clarify their roles.
export type MergedUnion<
src/index.ts:78
- This new
MergedUnionlogic introduces complex conditional and mapped types; consider adding dedicated type-level tests (e.g., viatsd) to verify all merge scenarios and edge cases.
export type MergedUnion<
Owner
Author
|
We should add another testing library to check actual types |
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.
Changes:
Closes #1 and closes #2