I think would be nice to patch the JavaScript codegen to add types, ...but using Facebooks FlowType, because is literally plain vanilla JavaScript with comments, types go inline tiny comments, kinda `/*: int */`, that way it can still run directly in anything that has a JavaScript interpreter, and you do not lose strict static typing, I would be interested on that.
Also making Nim comments emit JavaScript comments would be nice anyway. See <https://flow.org/en/docs/types/comments>