js: fix code generation for `$if js` statements (#6896)

pull/6912/head
pancake 2020-11-21 15:40:37 +01:00 committed by GitHub
parent 54df7d1daf
commit 4b19a6e00d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -1270,7 +1270,11 @@ fn (mut g JsGen) gen_if_expr(node ast.IfExpr) {
}
else {
g.write('if (')
g.expr(branch.cond)
if '$branch.cond' == 'js' {
g.write('true')
} else {
g.expr(branch.cond)
}
g.writeln(') {')
}
}