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

Minor update to JavaScriptParser to generate correct AST elements. #73

Merged
merged 1 commit into from
Nov 10, 2023

Conversation

traceyyoshima
Copy link
Contributor

@traceyyoshima traceyyoshima commented Nov 10, 2023

Changes:

  • JavaScriptParser creates test files with .ts extension instead of .js
  • Updated ts.config to match the script target in the runtime index.ts increateScanner()
  • Updated tests to fail when ParserErrors are detected in the source.

fixes #56

@traceyyoshima traceyyoshima requested a review from zieka November 10, 2023 04:54
@@ -3,9 +3,9 @@
"display": "Node 14",

"compilerOptions": {
"lib": ["es2020"],
"lib": ["esnext"],
Copy link
Member

@zieka zieka Nov 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I imagine this is fine for now; is the plan:

graph LR
    A[.ts file] -->|ts AST via tsc| B((ts AST))
    B -->|map to LST| C((LST))
    C -->|.ts file via openrewrite printer| D[.ts file]
Loading

Copy link
Contributor Author

@traceyyoshima traceyyoshima Nov 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the supported extensions are set to:

  • .js, .jsx, .mjs, .cjs
  • .ts, .tsx, .mts, .cts

There are a few configurations I am unsure of:

  1. Should we set the ScriptTarget based on the project? ES2000, ES2020, ESNEXT, etc.
  2. Is it safe to set the ScriptKind to the TS equivalent of a JS file (JS -> TS, JSX -> TSX), or should we let the extension set the behavior in the compiler?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know what the ScriptTarget settings affect in the compiler. I changed it so that the Scanner would be set to the same version of the lib and target in the compiler options.

@traceyyoshima traceyyoshima merged commit 0357e24 into main Nov 10, 2023
3 checks passed
@traceyyoshima traceyyoshima deleted the issue-56 branch November 10, 2023 06:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

TSCNode returns a BinaryExpression instead of a CallExpression
2 participants