rescript-association / genType

Auto generation of idiomatic bindings between Reason and JavaScript: either vanilla or typed with TypeScript/FlowType.

Home Page:https://rescript-lang.org/docs/gentype/latest/introduction

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

existential types produce invalid TS

johnridesabike opened this issue · comments

@gentype
type rec t = Any('a): t

output:

export type t = { tag: "Any"; value: a };
Cannot find name 'a'.
Property 'value' of exported interface has or is using private name 'a'.

There's no support for exporting GADTs at the moment. It's not clear what TS type they would map to.

Would it be possible for gentype to output type names like any or unknown for cases that aren’t supported? Or could it print a warning/error so the user can work around it? Either way, silently outputting invalid code seems unideal.

Indeed, it makes sense to give a warning in this case.
Doing it here: #504
Also, exporting it as opaque in that case, so it's a black box from TS.