Skip to content

Using single-line arrow functions can cause closure compiler to inject an extra return keyword`. #26922

@sbc100

Description

@sbc100

It seems like adding braces here actual makes the final output smaller:

 emscripten_console_log: (str) => { console.log(UTF8ToString(str)) }

Compared to:

emscripten_console_log: (str) => console.log(UTF8ToString(str))

It seems to happen when closure inlines UTF8ToString into emscripten_console_log. In the former case I supposed closure knows that the function returns undefined, but in the later case it adds an extra return keyword to return the result of the console.log call.

Maybe there is some way to teach closure that console.log always returns undefined so this is not needed?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions