fix(code-editor): allow extension on nested elements - #150
Merged
Conversation
resolveElements did not include the universal element properties (id, extension, and modifierExtension for BackboneElements) for nested backbone or complex elements, because a StructureDefinition differential does not repeat inherited base-type elements. This caused the FHIR editor to flag a valid `extension` on e.g. QuestionnaireResponse.item or Patient.contact as an "Unknown property", and to omit it from autocomplete. Append the universal properties to resolveElements output (when not already present), gated by whether the context is a BackboneElement/resource (modifierExtension) or a plain complex datatype (id/extension only). Both diagnostics and autocomplete now handle nested extensions correctly. Fixes HealthSamurai/sansara#8121 Co-Authored-By: Aleksandr Kislitsyn <aleksandr.kislitsyn@gmail.com> Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
CI `pnpm audit --audit-level=high` flagged brace-expansion advisories (GHSA-mh99-v99m-4gvg, GHSA-rgw5-rvv9-x895) in transitive deps via @swc/cli>minimatch and @storybook/react-*. The existing overrides did not cover the vulnerable ranges. Override brace-expansion 2.x to >=2.1.4 and 3.x-5.x to >=5.0.9. Audit at --audit-level=high now passes (only 2 moderate advisories remain, below the high threshold). Co-Authored-By: Aleksandr Kislitsyn <aleksandr.kislitsyn@gmail.com> Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This was referenced Aug 5, 2026
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.
Fixes HealthSamurai/sansara#8121.
Problem
The FHIR JSON editor flagged a valid
extensionon a nested element as anUnknown property, and did not offer it in autocomplete. Examples from the issue:QuestionnaireResponse.item[].extensionPatient.contact[].extensionBoth resources are valid and save fine — the editor's client-side validation was wrong.
Root cause
resolveElements(infhir-autocomplete.ts) drives both the diagnostics and the autocomplete. It resolves the valid child elements for a path by walking the StructureDefinition differentials.contact.name→HumanName), it descends viacollectAllElements(typeCode), which recurses intobaseDefinition(Element) and therefore picks up the inheritedid/extension.QuestionnaireResponse.item), there is no named type to resolve — its children live inline in the parent resource's differential. That branch just repoints the path and returns the inline children, and never merges in theBackboneElement/Elementbase fields. A differential doesn't repeat inherited elements, soid/extension/modifierExtensionwere missing.Result:
extensionon a nested backbone/complex element was neither recognized (→ false "Unknown property") nor suggested.Fix
Append the universal element properties to
resolveElementsoutput when not already present:id,extension— on every elementmodifierExtension— additionally on BackboneElements and resources (tracked via anisBackboneflag), not on plain complex datatypes likeHumanNameBecause both the diagnostics and autocomplete consume
resolveElements, this one change fixes both: no more false "Unknown property" on nested extensions, and autocomplete now suggestsextension(andmodifierExtensionwhere valid) inside nested backbone elements. Theif not already presentguard makes it a no-op at the resource root and for complex types, where these fields are already present.Verification
extensioninsideQuestionnaireResponse.item/Patient.contact, andmodifierExtensionon backbone items but not inside a plainHumanName.biome checkclean on the changed file;tsc -bno new errors.🤖 Generated with Claude Code