Skip to content

TypeScript Labeled Tuples #1357

@jplante

Description

@jplante

With TypeScript 4.0 they have introduced Labeled Tuples:
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-0.html#labeled-tuple-elements

The current tuple types in the JSON output from TypeDocs provides the following information about a tuple type:

elements:(2) [{…}, {…}]
  0:{
    type: 'intrinsic', 
    name: 'number'
  }
  1:{
    type: 'intrinsic', 
    name: 'number'
  },
type:'tuple'

As you can see the elements in the tuple do not include their labels.

Before in 3.x your tuple might be:

export type PointAlias = 
  | Point
  | { x: number, y: number }
  | [ number, number ]

This tuple above does not indicate the order of "x,y" or "y,x"

But with 4.x and labeled tuples you can provide:

export type PointAlias  = 
  | Point
  | { x: number, y: number }
  | [ x: number, y: number ]

However currently TypeDoc does not provide that extra meta-data about the tuple types.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions