An experimental TypeSpec syntax for Lexicon
56
fork

Configure Feed

Select the types of activity you want to include in your feed.

How to represent union of tokens with default value? #4

open opened by maxine.puppykitty.racing

Community Lexicon has a lexicon like this (paraphrased):

{
    "lexicon": 1,
    "id": "community.lexicon.calendar.event",
    "defs": {
        "mode": {
            "type": "string",
            "description": "The mode of the event.",
            "default": "community.lexicon.calendar.event#inperson",
            "knownValues": [
                "community.lexicon.calendar.event#hybrid",
                "community.lexicon.calendar.event#inperson",
                "community.lexicon.calendar.event#virtual"
            ]
        },
        "virtual": {
            "type": "token",
            "description": "A virtual event that takes place online."
        },
        "inperson": {
            "type": "token",
            "description": "An in-person event that takes place offline."
        },
        "hybrid": {
            "type": "token",
            "description": "A hybrid event that takes place both online and offline."
        }
    }
}

This maps almost to:

    /** The mode of the event. */
    @closed @inline
    union Mode {
        Hybrid,
        Inperson,
        Virtual,
    }

    /** A virtual event that takes place online. */
    @token
    model Virtual {}

    /** An in-person event that takes place offline. */
    @token
    model Inperson {}

    /** A hybrid event that takes place both online and offline. */
    @token
    model Hybrid {}

But I'm struggling to think of how to represent the default value in typelex.

sign up or login to add to the discussion
Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:nmc77zslrwafxn75j66mep6o/sh.tangled.repo.issue/3m344mgv5km22