Skip to content

Commit 13a959b

Browse files
tomblindPerryvw
authored andcommitted
fix for detection of first variable declarations when no variable statement can be accessed (#399)
1 parent 041d149 commit 13a959b

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/LuaTransformer.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3665,9 +3665,8 @@ export class LuaTransformer {
36653665
const insideFunction = this.findScope(ScopeType.Function) !== undefined;
36663666
let isLetOrConst = false;
36673667
let isFirstDeclaration = true; // var can have multiple declarations for the same variable :/
3668-
if (tsOriginal && ts.isVariableDeclaration(tsOriginal)) {
3669-
isLetOrConst = tsOriginal.parent
3670-
&& (tsOriginal.parent.flags & (ts.NodeFlags.Let | ts.NodeFlags.Const)) !== 0;
3668+
if (tsOriginal && ts.isVariableDeclaration(tsOriginal) && tsOriginal.parent) {
3669+
isLetOrConst = (tsOriginal.parent.flags & (ts.NodeFlags.Let | ts.NodeFlags.Const)) !== 0;
36713670
isFirstDeclaration = isLetOrConst || tsHelper.isFirstDeclaration(tsOriginal, this.checker);
36723671
}
36733672
if ((this.isModule || this.currentNamespace || insideFunction || isLetOrConst) && isFirstDeclaration) {

0 commit comments

Comments
 (0)