gleam icon indicating copy to clipboard operation
gleam copied to clipboard

Typescript generation: Cannot reproduce example from blog post

Open lucasavila00 opened this issue 1 year ago • 1 comments

On nightly and latest stable.

Given this input:

import gleam/io

pub const answer = 42

pub fn map(result, fun) {
  case result {
    Ok(a) -> Ok(fun(a))
    Error(e) -> Error(e)
  }
}

pub fn main() {
  map(Ok(456), io.debug)
}

I get

import * as io from "../../gleam_stdlib/dist/gleam/io.d.ts";
import * as _ from "./gleam.d.ts";

export const answer: number;

export function map(result: _.Result<any, any>, fun: (x0: any) => any): _.Result<
  any,
  any
>;

export function main(): _.Result<number, any>;

map is not generic.

What is the current approach used to test this feature? Are there snapshots for it?

lucasavila00 avatar Aug 08 '22 02:08 lucasavila00

Thank you

What is the current approach used to test this feature? Are there snapshots for it?

Yup, in with the JS tests there is a TS snapshot macro

lpil avatar Aug 08 '22 11:08 lpil