Skip to content
This repository was archived by the owner on Mar 18, 2026. It is now read-only.
This repository was archived by the owner on Mar 18, 2026. It is now read-only.

TypeScript bindings: abstract literal union types into separate types? #38

@aartaka

Description

@aartaka

So I'm working on translating some string fields from CCDA to FHIR. FHIR type definitions have a form of:

export interface PractitionerRoleAvailableTime extends BackboneElement {
    allDay?: boolean;
    availableEndTime?: string;
    availableStartTime?: string;
    daysOfWeek?: 'mon' | 'tue' | 'wed' | 'thu' | 'fri' | 'sat' | 'sun'[];
}

where daysOfWeek, for instance, is a union of literals type. There may be more than ten literals in this field's type. While I'm providing a meager string when setting this field. So TypeScript (justifiably) complains that string is not compatible with 'mon' | 'tue' | 'wed' | 'thu' | 'fri' | 'sat' | 'sun'.

I don't want to provide a full 'mon' | 'tue' | 'wed' | 'thu' | 'fri' | 'sat' | 'sun' as a type for every string I use for this field. Especially given how many literals there might be. Having an abstracted type (DayOfWeek) would be perfect for that.

But I realize that it might be hard to implement. Parsing ValueSets, I guess?

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