semgrep / pfff

pfff is mainly an OCaml API to write static analysis, dynamic analysis, code visualizations, code navigations, or style-preserving source-to-source transformations such as refactorings on source code.
https://semgrep.dev
Other
186 stars 29 forks source link

fix(js): Parse `New` as a separate construct from `Apply` #529

Closed nmote closed 2 years ago

nmote commented 2 years ago

My end goal is to allow Semgrep to infer the type from this:

const x = new Y();

In other languages, this works fine: there's some code that looks for a few common cases on the RHS of a variable definition and pulls out the type. However, because of some parsing oddities, in JS this ends up being parsed as a Call with some weird arguments.

Changing the pfff parser to separate New is the first step towards addressing this.

Test plan: Automated tests

Security