Gentype constructor type

I am trying to import a typescript error class using gentype like below.

type t
@new @genType.import("../lib/errors")
external myError: (int, string) => t = "MyError"

Gentype is not generating the proper constructor type in the generated .ts file like below.

type myError = new (number, string) => t

Please advise.

There’s no support for @new in genType.

1 Like

@cristianoc Thanks. I created additional pure functions and imported them using gentype instead.

// In my existing .ts file

class MyError { ... }

// Imported this in res file
export const createMyError = (n: number, s: string) => new MyError(n, s)
1 Like