TS: Add type discriminator support for slicing - #108
Merged
Conversation
ryukzak
force-pushed
the
resolve-collisions
branch
from
March 18, 2026 15:56
75be3df to
2f37b58
Compare
Compute resourceType-based match for type discriminators so slices discriminated by resource type (e.g. Bundle.entry by resource) generate getter/setter methods. Type-discriminated getters return items as-is (no stripMatchKeys) and input types don't Omit match fields.
… SDs Point local-package test at examples/local-package-folder/structure-definitions instead of maintaining a separate copy in test/assets.
Add SD, demo test, and tsconfig for local-package-folder example. Add test-local-package-folder-example make target with typecheck.
ryukzak
force-pushed
the
resolve-collisions
branch
from
March 18, 2026 16:02
2f37b58 to
7c47c68
Compare
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.
typediscriminator in slicing — match slices byresourceTypefieldfield-builder.ts: compute{ resource: { resourceType: "<Type>" } }match pattern from FHIRtypediscriminator path and element typeprofile-slices.ts: addtypeDiscriminatorflag toSliceDef; type-discriminated getters return items viaascast (nostripMatchKeys)profile.ts: skip match-field omission in flat input types andstripMatchKeysimport for type discriminator slicestypediscriminator status → PartialGenerated profile before (no type discriminator support — slices silently ignored):
// No PatientEntry/OrganizationEntry getters/setters generatedGenerated profile after (
ExampleTypedBundlewithBundle.entrysliced by resource type):Example & tests
ExampleTypedBundleStructureDefinition with Patient/Organization entry slicesprofile-typed-bundle.test.tsdemo covering create, set/get, validation, fluent chainingexamples/instead oftest/assets/)test-local-package-folder-exampletarget to Makefile