Skip to content

Update optional chaining representation to match ESTree spec #2204

@bradzacher

Description

@bradzacher

ESTree just merged the representation for optional chaining.
estree/estree#204

They chose a different representation to babel's representation, which we went with originally (as it was the only representation in the ecosystem).

We now need to update our parser to match this representation.

interface ChainExpression <: Expression {
  type: "ChainExpression"
  expression: ChainElement
}
interface ChainElement <: Node {
  optional: boolean
}
extend interface CallExpression <: ChainElement {}
extend interface MemberExpression <: ChainElement {}

In terms of timelines, we need to track ESLint here, as they will be moving to implement this as well. With it, they will update their lint rules to support it.


This is ofc a breaking change in the AST structure, and will unfortunately be a relatively painful one for consumers of our plugins.

I don't see this as being too painful, however. There will be some new false-negatives in the ecosystem due to the ChainExpression node, but because everything is now just a Call/MemberExpression, most of the plugins should "just work".


This is required to support ESLint 7.5.0, which added support to rules for optional chaining.
https://eslint.org/blog/2020/07/eslint-v7.5.0-released

Metadata

Metadata

Assignees

No one assigned

    Labels

    ASTPRs and Issues about the AST structurebreaking changeThis change will require a new major version to be releasedpackage: eslint-pluginIssues related to @typescript-eslint/eslint-pluginpackage: typescript-estreeIssues related to @typescript-eslint/typescript-estree

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy