rescript-compiler icon indicating copy to clipboard operation
rescript-compiler copied to clipboard

Missing type for `exn`

Open sgrove opened this issue 2 years ago • 2 comments

Exporting a function like:

@genType
let basicEvalNode = (
  ~onError: exn => unit,
) => {

Outputs the following TypeScript:

export const basicEvalNode: (_1: {
  readonly onError: (_1: exn) => void;

But exn is never defined/imported, so we get an error:

src/HyperEval.gen.tsx:38:17 - error TS2304: Cannot find name 'exn'.
38   onError: (_1: exn) => void,

It'd be nice to even export it as unknown, since that would allow TypeSCript to continue


One small hack I've found is to make a type alias but mark it opaque and use that instead, e.g.:

@genType.opaque
type userExn = exn

Obviously not ideal from the Javascript/Typescript side of things, but it means TypeScript can at least compile and doesn't block things for a bit.

sgrove avatar Aug 20 '23 17:08 sgrove

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Sep 02 '24 01:09 github-actions[bot]

Not yet bot!

fhammerschmidt avatar Sep 02 '24 11:09 fhammerschmidt

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Aug 29 '25 02:08 github-actions[bot]