TS: Split slice flat types into SliceFlat/SliceFlatAll with discriminator literals#127
Merged
TS: Split slice flat types into SliceFlat/SliceFlatAll with discriminator literals#127
Conversation
Add optional discriminator fields with literal types to slice flat types.
Skip for constrained choice slices (field name collisions) and plain
object match values (partial objects conflict with required base fields).
Before: `Omit<CodeableConcept, "coding">`
After: `Omit<CodeableConcept, "coding"> & { coding?: [{ code: "vital-signs"; system: "..." }] }`
…ntation) SliceInput has no discriminator fields — used by setters and getter return. SliceFlat extends SliceInput with readonly discriminator literal types — available as a type-level reference for documentation.
…stripping them getVSCat() now returns the item cast to SliceFlat (which includes readonly discriminator fields) instead of calling stripMatchKeys to remove them. This makes the runtime value match the type — flat.coding is actually present.
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.
Summary
SliceFlat(setter input) andSliceFlatAll(getter return with discriminators)SliceFlat— no discriminator fields, used as setter parameterSliceFlatAll— extendsSliceFlatwith readonly discriminator literal types, returned by flat getterSliceMatchstatic fields andSliceFlatAlltypes are split across multiple linesBefore:
After:
Closes #122