Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

AST standardisation: removeundefined/optional from node properties unless it really makes sense #5020

Closed
Labels
ASTPRs and Issues about the AST structureaccepting prsGo ahead, send a pull request that resolves this issuebreaking changeThis change will require a new major version to be releasedenhancementNew feature or request
Milestone
@bradzacher

Description

@bradzacher

Across the AST we have a lot of cases where we've made properties optional.
I think there were various reasons for why it was done this way (not that I can find the comments any more).

From the perspective of an AST consumer,undefined can create some very weird states. Two examples of this:

  1. There are a number ofboolean properties that are optional. On the surface this makes it look like the property with 3 meaningful states (true,false, orundefined), even though in reality it only ever actually represents 2 states.
    Usually in these cases the parser emitstrue orundefined (and neverfalse), and in some rarer cases it emitstrue, and then usesfalse orundefined interchangeably depending on some internal, obfuscated criteria.
  2. There are a few cases where an array property is optional. In these cases usually the parser will never emit an empty array, and will instead emitundefined.
    • From a memory-usage perspective, this could be justified (an empty array is really a heavy "empty" marker). But if that is our goal then these cases should be typed so that it is clear that there are never 0 elements (eg by defining[Foo, ...Foo[]])

We should standardise the AST to removeundefined/optional from all places, unless there is a very good reason for it to be optional.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ASTPRs and Issues about the AST structureaccepting prsGo ahead, send a pull request that resolves this issuebreaking changeThis change will require a new major version to be releasedenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp