scala-js-ts-importer icon indicating copy to clipboard operation
scala-js-ts-importer copied to clipboard

Feature: Optional field foo? should be translated to js.UndefOr

Open exoego opened this issue 6 years ago • 2 comments

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]

exoego avatar Jan 30 '19 11:01 exoego

The link to the TypeScript documentation you gave is about optional parameters, but your issue talks about optional fields.

sjrd avatar Jan 30 '19 11:01 sjrd

Sorry, updated the links.

exoego avatar Jan 30 '19 11:01 exoego