openrewrite / openrewrite/rewrite

TypeScript parsing uses strict mode

Open
#6,162 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

javascript parser
Dominant language
Java
Stars
3.7k
Forks
570
Avg merge
13h 12m
Merged PRs (30d)
261

Description

I noticed JavaScript parser seems to be using the strict mode to parse TypeScript/JavaScript code, which results in some pieces of code (not too many!) having parse errors. And assuming no-one is fixing them, they are likely working fine outside of OpenRewrite.

Examples:

Compiler error(s): (29,47): Octal literals are not allowed. Use the syntax '0o777'. 

with https://github.com/Unitech/pm2/blob/2c444715534a547fab5c7a6eb5819e6cd71e8714/test/programmatic/flagExt.mocha.js#L29

or

SyntaxError: Compiler error(s): (7495,76): The body of an 'if' statement cannot be the empty statement. [1313];

with https://github.com/nexus-stc/stc/blob/f65119dfba529bb989e8d23fb2dcb423c0d7ecf1/web/src/components/djvu.ts#L7495C7-L7495C77

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the JavaScript/TypeScript parser and its strict-mode configuration, then reproduce the examples from pm2's test/programmatic/flagExt.mocha.js and stc's web/src/components/djvu.ts. Determine how parsing should handle these non-strict constructs and add coverage for the reported cases. Done means the examples parse without the reported errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.