scala-js-ts-importer
scala-js-ts-importer copied to clipboard
Feature: Optional field foo? should be translated to js.UndefOr
TypeScript has foo? notation to indicate optional (can be null/undefined) type
Currently, scalajs-ts-importer converts foo?: T; into foo: T which can not accept js.undefined.
https://github.com/sjrd/scala-js-ts-importer/blob/12bc022dbf6345df96ac4950532cb7c178b22ddd/samples/numberlit.d.ts#L9
https://github.com/sjrd/scala-js-ts-importer/blob/12bc022dbf6345df96ac4950532cb7c178b22ddd/samples/numberlit.d.ts.scala#L12
I think it should be converted to js.UndefOr[T]
The link to the TypeScript documentation you gave is about optional parameters, but your issue talks about optional fields.
Sorry, updated the links.