Currently, variables/functions are declared locally and exported at the end of their block.
TS:
export let x = 12;
x = x + 13;
local exports = exports or {}
local x = 12;
x = (x+13);
exports.x = x
return exports
We should change the translation to:
local exports = exports or {}
exports.x = 12;
exports.x = exports.x + 13;
The problem is that there is no easy way to find out if an variable/identifier was exported after declaration.
Possible Solutions:
-
Check if export flag is set in the variablestatement parentOf(checker.getType(identifier).getSymbol().Declarations[0] and check the parent node for export modifier
-
Check the sourcefile or namespace symbol's export table and check if the identifiers symbol is in that table this.checker.getTypeAtLocation(this.sourceFile).getSymbol().exports.includes(this.checker.getTypeAtLocation(identifier)) or this.checker.getTypeAtLocation(this.currenNamespace).getSymbol().exports.includes(this.checker.getTypeAtLocation(identifier))
This should be probably be handled in the transformer (#278);
Currently, variables/functions are declared locally and exported at the end of their block.
TS:
We should change the translation to:
The problem is that there is no easy way to find out if an variable/identifier was exported after declaration.
Possible Solutions:
Check if export flag is set in the variablestatement
parentOf(checker.getType(identifier).getSymbol().Declarations[0]and check the parent node for export modifierCheck the sourcefile or namespace symbol's export table and check if the identifiers symbol is in that table
this.checker.getTypeAtLocation(this.sourceFile).getSymbol().exports.includes(this.checker.getTypeAtLocation(identifier))orthis.checker.getTypeAtLocation(this.currenNamespace).getSymbol().exports.includes(this.checker.getTypeAtLocation(identifier))This should be probably be handled in the transformer (#278);