core
core copied to clipboard
Types for local variables
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
varhoisting logic to allowletdeclarations do not declare separately if initial value can be set immediately.
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.