Skip to content

Compiler warnings / errors for common automatic semi-colon insertion (ASI) issues #2575

Closed
@jeffmay

Description

@jeffmay

Personally, I like the look (and simplicity) of ECMA6 / TypeScript without semi-colons. The only problem is that there are some known danger-zones with automatic semi-colon insertion. Could we have compiler warnings to prevent these from slipping through the cracks?

Example:

function dangerous(): string {
    return
        "watch the semi-colons!"
}
dangerous()

Compiles to the following with no warnings or compiler errors (even though the function actually doesn't return a string):

function dangerous() {
    return;
    "watch the semi-colons!";
}
dangerous();

This specific case is kind of scary / annoying, but it might be worth looking into others.

Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    FixedA PR has been merged for this issueSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions