Skip to content
This repository was archived by the owner on Jan 19, 2019. It is now read-only.
This repository was archived by the owner on Jan 19, 2019. It is now read-only.

i++ should be parsed as UpdateExpression/++ rather than UnaryExpression/PlusPlusToken #58

Closed
@danvk

Description

@danvk

I ran into this while debugging why this got flagged with eslint:

let i = 0;
function f() {
  i++;
}
f();

The error is 'i' is never reassigned. Use 'const' instead.

The esprima parse for the i++ looks like this:

          {
            "expression": {
              "argument": {
                "name": "i",
                "type": "Identifier"
              },
              "operator": "++",
              "prefix": false,
              "type": "UpdateExpression"
            }

whereas the typescript-eslint-parser equivalent is:

            "expression": {
              "argument": {
                "name": "i",
                "type": "Identifier"
              },
              "operator": "PlusPlusToken",
              "prefix": false,
              "type": "UnaryExpression"
            }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions