glutinum-org / cli

Home Page:https://glutinum.net/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support optional type in tuples

MangelMaxime opened this issue · comments

TypeScript documentation:

export type LatLngTuple = [number, number, number?];

translates into

type LatLngTuple =
    float * float * float option

This is not a perfect representation, but the more user friendly from F# point of view (avoid erased types).

Example of usage in TypeScript

export type LatLngTuple = [number, number, number?];

const coord : LatLngTuple = [1, 2, 3];
const coord1 : LatLngTuple = [1, 2];
const coord2 : LatLngTuple = [1, 2, null]; // Invalid
const coord3 : LatLngTuple = [1, 2, undefined]; 

Example of npm package using this features:

Leaflet