Skip to content

Add support for tuples #1634

@luis-j-soares

Description

@luis-j-soares

This is likely too close to Generics support, but we could use some way to define arrays with fixed element count and types.

Typescript does it with tuple types:

type StringNumberPair = [string, number];

function doSomething(pair: StringNumberPair) {
  const a = pair[0];
//      ^ const a: string
  const b = pair[1];
//      ^ const b: number

  // ...
}
 
doSomething(["hello", 42]);

I think the syntax here could be the same as Typescript's.

Metadata

Metadata

Assignees

No one assigned

    Labels

    New Language FeatureA proposal for a new feature to be added to the BrighterScript languageenhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions