fkling / astexplorer

A web tool to explore the ASTs generated by various parsers.
https://astexplorer.net/
MIT License
6.14k stars 729 forks source link

Add support for question mark operator in plugin input. #634

Open LeoDog896 opened 2 years ago

LeoDog896 commented 2 years ago

I've only tested this with the babel plugin, but when doing something as:

if (path.loc?.start == null) return, it won't work, even though that's a TypeScript operator.

It may be due to the fact that the typescript parser is used -- whenever possible, I'll look into it and PR it.

willklein commented 2 years ago

I'm having this problem too. using recast + jscodeshift.

Here's a snippet repro: https://astexplorer.net/#/gist/3ded4452dfbf415a9d47cb678e0f2266/1b92172a7cacf976ef1da962dff0974fdf48e440

I get an error in the output window:

unknown: Unexpected token (5:18)
  3 | export const parser = 'babel'
  4 | 
> 5 | unsupportedSyntax?.notWorking;

I don't know when I'll get a chance to dig in and debug AST Explorer, but I'll try.