cincheo / jsweet

A Java to JavaScript transpiler.
http://www.jsweet.org
Other
1.45k stars 159 forks source link

is it possible to generate ts code that is compatible with TS strict mode? #680

Closed xdenser closed 3 years ago

xdenser commented 3 years ago

In Java all non-primitive variables are 'nullable', this is not so in TS in strict mode. If some (field or variable) is declared as foo: string; You cannot just assign null or undefined to foo. To be compatible it should look like foo: string | null = null; or foo?: string | null; The same applies to all no-primitive function return types - they are nullable. Well propper implementation could include some analysis - if the code actually can return null. Also "meta" informations like this (also not valid in ts strict mode): SomeClass["__class"] = "my.package.ParsedDateFormat"; may be done like this static __class = "my.package.ParsedDateFormat" but in class body.

lgrignon commented 3 years ago

Duplicate of https://github.com/cincheo/jsweet/issues/554