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

fix: Fix marker function parsing when used after bracket syntax casting expression #45

Conversation

pmpak
Copy link

@pmpak pmpak commented Apr 27, 2024

The issue is that the tsquery.ast defaults to parsing the source as TSX, which causes problems when bracket syntax casting (<Type>) is used. This is because the parser confuses the casting syntax with JSX. To resolve this, we need to explicitly set the ScriptKind parameter to TS.

In the ast function description is also suggested to use ScriptKind.TS if the code uses the <Type> syntax for casting.

"If you are using the <Type> syntax for casting, you should use ScriptKind.TS."
https://github.com/phenomnomnominal/tsquery/blob/master/src/ast.ts#L12

This change ensures that the parser passes the correct ScriptKind to the ast function based on the source file extension, so that for .ts files it avoids the confusion with JSX and preventing parsing errors.

Fixes #43

@pmpak pmpak force-pushed the fix/angle-bracket-syntax-casting-makes-marker-call-to-be-ignored branch from f696f64 to 77eaa62 Compare April 27, 2024 18:36
@michaelbromley michaelbromley merged commit 1bd6d8b into vendure-ecommerce:master May 14, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cast with <> in Typescript breaks marker function parsing
2 participants