Skip to content

Return statements followed by an operand or a bracket get transpiled into invalid JavaScript #3

@JochCool

Description

@JochCool

When you transpile code that contains a return statement that returns an object (such as {a: a, b: b}), the result is invalid JavaScript. When running it, you get: SyntaxError: Unexpected token ':' (referring to the second colon).

How to reproduce

  1. Transpile the following code:
var a = 1, b = 2;
function test() {
	return { a: a, b: b };
};
console.log(test());
  1. Run the original code. The output is { a: 1, b: 2 }.
  2. Run the transpiled code. There is a syntax error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions