-
-
Notifications
You must be signed in to change notification settings - Fork 867
fix(estree): ExportNamedDeclaration.exportKind should be type for declare export
#10387
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -820,6 +820,28 @@ impl ESTree for ExportAllDeclarationWithClause<'_, '_> { | |
| } | ||
| } | ||
|
|
||
| #[ast_meta] | ||
| #[estree( | ||
| ts_type = "ImportOrExportKind", | ||
| raw_deser = " | ||
| const exportKind = DESER[ImportOrExportKind](POS_OFFSET.export_kind); | ||
| THIS.declaration?.declare ? 'type' : exportKind | ||
| " | ||
| )] | ||
| pub struct ExportNamedDeclarationExportKind<'a, 'b>(pub &'b ExportNamedDeclaration<'a>); | ||
|
|
||
| impl ESTree for ExportNamedDeclarationExportKind<'_, '_> { | ||
| fn serialize<S: Serializer>(&self, serializer: S) { | ||
| if let Some(decl) = &self.0.declaration { | ||
| if decl.declare() { | ||
| ImportOrExportKind::Type.serialize(serializer); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder whether this is a parser bug, where
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the review. I tried to fix parser at first, but other tests like codegen, isolated_decls failed, so I switched to this one. 😓
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we need to fix the parser so that consumers of this AST node knows it's a type export. To test the theory, we can find a linter rule and double check, e.g. I haven't checked, but we may be linting this node incorrectly.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, I think I got it this time. => #10389 Since it seems that |
||
| return; | ||
| } | ||
| } | ||
| self.0.export_kind.serialize(serializer); | ||
| } | ||
| } | ||
|
|
||
| // -------------------- | ||
| // JSX | ||
| // -------------------- | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First I tried this. But this seems to generate invalid JS code as a result. 🤔