aeson-typescript icon indicating copy to clipboard operation
aeson-typescript copied to clipboard

Haskell types with a `'` in the name result in broken code

Open parsonsmatt opened this issue 2 years ago • 0 comments

Suppose we have this:

data MyThing' a = MyThing a | Nope Int

$(deriveToJSONAndTypeScript defaultOptions ''MyThing')

It'll generate code like this:

export type TMyThing'<T> = IMyThing<T> | INope<T>

type IMyThing<T> = {
  tag: "MyThing"
  contents: T
}

type INope<T> = {
  tag: "Nope"
  contents: number
}

TypeScript fails to parse this.

It'd be nice if the TH code threw an error about it, instead.

parsonsmatt avatar Oct 27 '22 18:10 parsonsmatt