Skip to content
This repository was archived by the owner on Aug 31, 2023. It is now read-only.
This repository was archived by the owner on Aug 31, 2023. It is now read-only.

🐛 Update parser to support satisfies keyword (Typescript 4.9+) #3748

@lildeadprince

Description

@lildeadprince

Environment information

CLI:
  Version:              10.0.1
  Color support:        true

Platform:
  CPU Architecture:     x86_64
  OS:                   windows

Environment:
  ROME_LOG_DIR:         unset
  NO_COLOR:             unset
  TERM:                 "cygwin"

Rome Configuration:
  Status:               loaded
  Formatter disabled:   false
  Linter disabled:      true

Workspace:
  Open Documents:       0

Discovering running Rome servers...

Server:
  Status:               stopped

What happened?

Today (Nov 15 2022) Typescript 4.9 reaches planned release date. The brand new satisfies keyword is coming into play.

The updates for that keyword has already been included before in other tools like esbuild (since 0.5.14) and SWC (since 1.3.15).

Rome tools right now fail (playground link) to parse code containing such keyword:

Error log
> rome format ./src --write

./index.ts:12:3 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  × Expected a semicolon or an implicit semicolon after a statement, but found none

    10 │   blue: [0, 0, 255],
    11 │ //  ~~~~ The typo is now caught!
  > 12 │ } satisfies Record<Colors, string | RGB>;
       │   ^^^^^^^^^
    13 │ 

  i An explicit or implicit semicolon is expected here...

    10 │   blue: [0, 0, 255],
    11 │ //  ~~~~ The typo is now caught!
  > 12 │ } satisfies Record<Colors, string | RGB>;
       │   ^^^^^^^^^
    13 │ 

  i ...Which is required to end this statement

     5 │ type RGB = [red: number, green: number, blue: number];
     6 │ 
   > 7 │ const palette = {
       │ ^^^^^^^^^^^^^^^^^
   > 8 │   red: [255, 0, 0],
   > 9 │   green: '#00ff00',
  > 10 │   blue: [0, 0, 255],
  > 11 │ //  ~~~~ The typo is now caught!
  > 12 │ } satisfies Record<Colors, string | RGB>;
       │ ^^
    13 │ 


Expected result

satisfies keyword is expected to be parsed correctly.

I guess it should not be very complex, but unfortunately I'm not familiar enough with Rust. Furthermore, it is code related to the parser core (and files generated from I have no idea what source).
Therefore I won't try fixing it and filing a PR myself

Code of Conduct

  • I agree to follow Rome's Code of Conduct

Metadata

Metadata

Assignees

Labels

A-ParserArea: parserS-WishlistPossible interesting features not on the current roadmap

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions