Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] Discrepencies in results between JavaScript and TypeScript #1087

Closed
Pamplemousse opened this issue Apr 23, 2024 · 4 comments
Closed

[bug] Discrepencies in results between JavaScript and TypeScript #1087

Pamplemousse opened this issue Apr 23, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@Pamplemousse
Copy link

Trying to match and rewrite lambda functions in TypeScript, I get a simple pattern that doesn't work, but matches correctly in JavaScript.

⏯ Playground Link

Issue can't be reproduced in a single playground, as it is about inconsistencies between pattern matching in JavaScript and TypeScript.

💻 Code

# yolo.ts
const foo = (x) => bar(x);

🙁 Actual behavior

$ ast-grep run -p '($P) => $F($P)' yolo.ts
# nothing

$ ast-grep run --lang typescript -p '($P) => $F($P)' yolo.ts
# nothing

$ ast-grep run --lang javascript -p '($P) => $F($P)' yolo.ts
yolo.ts
1│const foo = (x) => bar(x);

🙂 Expected behavior

I was expecting the first pattern to match the code in TypeScript, like it does when the language is explicitly set to JavaScript.

@Pamplemousse Pamplemousse added the bug Something isn't working label Apr 23, 2024
@HerringtonDarkholme
Copy link
Member

The problem is first $P captures requried_parameter instead of identifier. But the second $P expects identifier

image

@HerringtonDarkholme
Copy link
Member

I have made pattern more permissive and it will be released in 0.21.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants