Skip to content

TS: Include fixed discriminator values in slice flat types #122

@ryukzak

Description

@ryukzak

Currently, slice flat types strip discriminator keys entirely:

export type Observation_bodyweight_Category_VSCatSliceFlat = Omit<CodeableConcept, "coding">;

This makes the type look useless — it's a CodeableConcept minus coding, leaving only text, id, and extension.

Proposal

Include the discriminator values as literal types instead of omitting them:

export type Observation_bodyweight_Category_VSCatSliceFlat = Omit<CodeableConcept, "coding"> & {
    coding: [{ code: "vital-signs"; system: "http://terminology.hl7.org/CodeSystem/observation-category" }];
};

This way the flat type carries the fixed discriminator value at the type level, which is useful for type-level checks and documentation. The flat getter would continue to strip discriminator keys at runtime.

Scope

  • Affects src/api/writer-generator/typescript/profile.ts and profile-slices.ts
  • Applies to all slice flat types across all profiles (VSCat, SystolicBP, DiastolicBP, etc.)

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