Skip to content

Support non-null assertion operator after array dereference #107

@mjambon

Description

@mjambon

This code was found in the wild:

lastDstToken.parts[0]! += token.parts[0];

The parser is confused by the exclamation mark. A simpler test case that also fails is:

a[0]! += 2

and also

a[0]! = 2

This feature would be useful if the typescript type checker could show a warning when a[0] could be unset, causing an error when adding something to it. I haven't managed to obtain such warning in the typescript playground, so I wonder if this syntax is widely used.

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