TS: accept all FHIR literal reference forms in Reference<T>#144
Merged
TS: accept all FHIR literal reference forms in Reference<T>#144
Conversation
Fixes #141. The generated Reference<T> type narrowed reference to `${T}/${string}`, which rejected other forms allowed by the FHIR spec (urn:uuid, urn:oid, absolute URLs, fragments). The field type is now a union covering: relative `${T}/${string}`, absolute `http://…` / `https://…`, Bundle placeholder `urn:uuid:…`, OID `urn:oid:…`, and contained fragment `#…`.
Add a demo in examples/typescript-r4/resource.test.ts that assigns each of the six allowed literal forms (relative, urn:uuid, urn:oid, http, https, fragment) to a typed Reference field, so the widened template-literal union is exercised by tsc.
Regenerate src/fhir-types and the typescript-r4/typescript-us-core example fhir-types to reflect the widened Reference.reference union.
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.
Closes #141.
Changes
Reference<T>.referencefield from`${T}/${string}`to a union that covers every form allowed by FHIR references: relative, absolutehttp/https,urn:uuid,urn:oid, and#fragment.examples/typescript-r4/resource.test.tsthat assigns each literal form to a typed Reference field, so the widened union is exercised bytsc.src/fhir-typesand thetypescript-r4/typescript-us-coreexample fhir-types.Before / after
Motivation:
Reference<"Patient">was rejectingurn:uuidplaceholders used in transaction Bundles, forcing an inline cast that lies about the string's shape.Before:
After: