Skip to content

TypeScript generator does not emit SimpleQuantity (constrained Quantity) #177

@bkaney

Description

@bkaney

Summary

The TypeScript generator is not emitting a type for SimpleQuantity. This appears to be because SimpleQuantity is represented as a constraint on Quantity rather than as a full standalone type in the same way other specializations are.

Other datatype specializations (e.g., Count) are generated correctly, but SimpleQuantity is missing from the TypeScript output.

Background / Context

For illustration:

SimpleQuantity

Is a constraint of the Quantity type (e.g., limitation of comparator, UCUM focus, etc.), and is defined in FHIR as a profile/specialization of Quantity.

Count

Declares a Count type (specialization of Quantity) and is treated as a proper structure so code is emitted for it.

In general, the generator processes profiles and specializations correctly for many target languages. However, the TypeScript generator appears to skip these constrained profiles because “it has nothing useful to say” in its current logic, so no SimpleQuantity type gets generated.

The result is that any FHIR definition that references SimpleQuantity has no corresponding TypeScript type emitted.

Steps to Reproduce

Run the TypeScript generator on the R4 core spec using fhir-codegen. Inspect the output for datatype definitions.

Note that:

  • Quantity and Count are generated.
  • SimpleQuantity is not generated.

Expected Behavior

The TypeScript generator should emit a SimpleQuantity type that corresponds to the FHIR SimpleQuantity definition, analogous to how it emits Count as a specialization of Quantity. This allows downstream TypeScript projects to reference SimpleQuantity where it appears in the FHIR spec.

For example, we’d expect something like a SimpleQuantity interface or type alias that reflects the constraints applied to Quantity for elements that specifically reference SimpleQuantity.

Actual Behavior

SimpleQuantity is not generated at all in the TypeScript output.

References to SimpleQuantity in FHIR resources end up effectively pointing to Quantity (or nothing explicit), losing the semantic distinction and constraints.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions