Skip to content

Option to label tuple elements #529

Open
@DrJonki

Description

@DrJonki

I'm working on a custom RPC-like client-server communication layer, where I publish the back-end schema as JSON, and using this tool (thanks, BTW 🙂) I generate TypeScript for the frontend code to utilize. It's working great, for the most part, but there's one thing missing that I would find very useful.


{
  "id": "test-schema",
  "items": [
    {
      "type": "number",
      "title": "NumberItem"
    },
    {
      "type": "string",
      "title": "StringItem"
    }
  ],
  "minItems": 2,
  "additionalItems": false
}

Currently the above schema is generated into this.

export type TestSchema = [NumberItem, StringItem];
export type NumberItem = number;
export type StringItem = string;

I would like to have the option to use tuple element labels instead of separate named types, so that the generated tuple would look like this instead of the above.

export type TestSchema = [numberItem: number, stringItem: string];

This would allow for better intellisense when the generated tuple is used as a type for a function spread parameter.
Untitled


I'd be willing to try to implement this if maintainers think it's a good idea.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions