core icon indicating copy to clipboard operation
core copied to clipboard

Types for local variables

Open Jand42 opened this issue 8 years ago • 1 comments

Persist types of local variables to translate to TypeScript. Only include them if they have to be declared in undefined state, a let x = value is able to set type of x from value but a var x or let x; would be type any.

  • [x] Persist and print types
  • [ ] Revise previous var hoisting logic to allow let declarations do not declare separately if initial value can be set immediately.

Jand42 avatar Oct 16 '17 08:10 Jand42

An issue with the current handling of this: https://github.com/intellifactory/websharper/blob/b9a67e06ed29c4ec9952777dc75c9ec0b6b987f4/src/stdlib/WebSharper.Main/JavaScript.Pervasives.fs#L100-L104

The line let r = JS.Inline "{}" is compiled to var r={};, and therefore r is inferred to have type {}, whereas we would like it to be any.

Tarmil avatar Oct 18 '17 09:10 Tarmil