feat(ast/estree)!: option to return JS-only AST#9520
Merged
graphite-app[bot] merged 1 commit intomainfrom Mar 4, 2025
Merged
Conversation
Member
Author
CodSpeed Performance ReportMerging #9520 will create unknown performance changesComparing Summary
Benchmarks breakdown
|
673323e to
fcbec75
Compare
fcbec75 to
8ba8c68
Compare
8ba8c68 to
e477f85
Compare
3e256d7 to
30732cc
Compare
Contributor
Merge activity
|
Add an `astType` option to `parseSync` and `parseAsync`. When set to `'js'`, the returned AST does not include TypeScript-related properties. When set to `'ts'`, it does. If not specified, the option defaults to same as source type. So when parsing JS / JSX files, the AST returned does not include TS properties by default. The motivation for allowing the user to override that behavior, is in case someone is parsing a mix of JS and TS files, and want all the ASTs in the same format. In that case they'd set `astType: 'ts'` for all files. This is a breaking change as it alters what properties appear in the AST on JS side.
30732cc to
d55dbe2
Compare
e477f85 to
4056560
Compare
Base automatically changed from
03-03-feat_ast_estree_raw_transfer_experimental_
to
main
March 4, 2025 14:45
This was referenced Mar 4, 2025
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Add an
astTypeoption toparseSyncandparseAsync.When set to
'js', the returned AST does not include TypeScript-related properties. When set to'ts', it does.If not specified, the option defaults to same as source type. So when parsing JS / JSX files, the AST returned does not include TS properties by default.
The motivation for allowing the user to override that behavior, is in case someone is parsing a mix of JS and TS files, and want all the ASTs in the same format. In that case they'd set
astType: 'ts'for all files.This is a breaking change as it alters what properties appear in the AST on JS side.