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(ast/estree): fix TSImportType #9670

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

hi-ogawa
Copy link
Contributor

@hi-ogawa hi-ogawa commented Mar 11, 2025

@github-actions github-actions bot added A-ast Area - AST C-bug Category - Bug labels Mar 11, 2025
Copy link
Contributor Author


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@hi-ogawa
Copy link
Contributor Author

Ah, I just realized this is being handled in #9665 😅 Closing

@hi-ogawa hi-ogawa closed this Mar 11, 2025
@hi-ogawa
Copy link
Contributor Author

Or maybe I misunderstood the PR #9664 🤔 Will it be still required to do special serialization for TSImportType.options as per the issue? @Boshen

@hi-ogawa hi-ogawa reopened this Mar 11, 2025
@hi-ogawa hi-ogawa force-pushed the 03-11-fix_ast_estree_fix_tsimporttype branch from 02d03bd to e91439f Compare March 11, 2025 05:44
Copy link

codspeed-hq bot commented Mar 11, 2025

CodSpeed Performance Report

Merging #9670 will not alter performance

Comparing 03-11-fix_ast_estree_fix_tsimporttype (f05e966) with main (89b6e4c)

Summary

✅ 39 untouched benchmarks

@hi-ogawa hi-ogawa force-pushed the 03-11-fix_ast_estree_fix_tsimporttype branch from 5bc5313 to f05e966 Compare March 11, 2025 06:58
@overlookmotel
Copy link
Contributor

overlookmotel commented Mar 11, 2025

I'm also not clear on if this is needed or not. But, if it is needed, I think you could put #[estree(via = ...)] on just the elements field of TSImportAttributes, rather than on the whole type. Handle the other differences with #[estree(rename = "ObjectExpression")] on the type, and #[estree(rename = "properties")] on the field.

Unfortunately we can't avoid custom serializers/deserializers for these kind of cases, but in my view the smaller we can keep them, the better. It's easy for the Rust and JS implementations to get out of sync, and at some point soon we'll also add support for transferring ASTs in the other direction (JS -> Rust), at which point we'll also need to add (1) a JS serializer and (2) a Rust deserializer for all these custom cases. Inevitably it's going to get a bit messy, but it's ideal to minimize that mess as much as we can.

PS: Hope you're enjoying the bizarre torture of writing the raw_deser impls! I will try to improve that. I only got as far as the bare minimum to make it work. Definitely needs improvement.

attributesKeyword: IdentifierName;
elements: Array<TSImportAttribute>;
}

export interface TSImportAttribute extends Span {
Copy link
Contributor

@ArnaudBarre ArnaudBarre Mar 11, 2025

Choose a reason for hiding this comment

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

Can this be omitted from the typegen? (with TSImportAttributeName)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ast Area - AST C-bug Category - Bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ast: serialize TSImportType.options as ObjectExpression
3 participants