-
Notifications
You must be signed in to change notification settings - Fork 589
Reparse @import
as synthetic type-only import declaration
#831
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
base: main
Are you sure you want to change the base?
Conversation
It is slightly stricter than Strada's treatment because Corsa now treats the synthetic node *exactly* as a type-only declaration.
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.
Pull Request Overview
This PR introduces a new syntax node (KindJSImportDeclaration) to support the re-parsing of @import annotations as synthetic type‑only import declarations. The updates ensure that all relevant components—including transformers, printers, checkers, AST utilities, and unit tests—properly recognize and handle the new Kind alongside the traditional import declaration.
- Extended switch-case statements and error handling in multiple modules to include KindJSImportDeclaration.
- Updated AST creation methods and reparse logic to correctly mark synthetic jsimport declarations as type‑only.
Reviewed Changes
Copilot reviewed 52 out of 53 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
testdata/baselines/reference/submodule/conformance/importTag15(module=esnext).errors.txt | Adjusted error output to account for the additional type‑only import errors. |
testdata/baselines/reference/submodule/conformance/importTag15(module=es2015).errors.txt | Updated error messages and counts for invalid use of import attributes. |
internal/transformers/typeeraser.go | Added KindJSImportDeclaration in the type eraser transformer to ensure proper traversal. |
internal/transformers/importelision.go | Extended import elision logic to handle synthetic jsimport declarations. |
internal/transformers/externalmoduleinfo.go | Modified external module info collection to include KindJSImportDeclaration. |
internal/transformers/esnext.go | Updated transformer switch to recognize KindJSImportDeclaration. |
internal/transformers/esmodule.go | Added a case to handle KindJSImportDeclaration during ES module transformation. |
internal/transformers/commonjsmodule.go | Added handling for KindJSImportDeclaration as a no‑op, aligning with CommonJS semantics. |
internal/printer/printer.go | Extended the printer to generate nodes for KindJSImportDeclaration. |
internal/printer/namegenerator.go | Modified name generation logic to include KindJSImportDeclaration along with existing types. |
internal/parser/reparser.go | Implemented reparse logic for @import JSDoc tags to create synthetic jsimport declarations marked as type‑only. |
internal/ls/utilities.go | Updated language service utilities to recognize KindJSImportDeclaration in import specifier resolution. |
internal/checker/grammarchecks.go | Adjusted grammar checks to include KindJSImportDeclaration when validating ambient import modifiers. |
internal/checker/checker.go | Integrated KindJSImportDeclaration in multiple checking routines for import declarations. |
internal/ast/utilities.go | Updated various AST utility functions to support KindJSImportDeclaration in their logic. |
internal/ast/kind_stringer_generated.go | Revised generated string mappings to include KindJSImportDeclaration. |
internal/ast/kind.go | Declared the new constant KindJSImportDeclaration. |
internal/ast/ast.go | Updated factory methods for creating import declarations to allow creation of KindJSImportDeclaration. |
Files not reviewed (1)
- testdata/baselines/reference/submodule/conformance/importTag1.errors.txt: Language not supported
testdata/baselines/reference/submoduleAccepted/conformance/importTag16.types.diff
Show resolved
Hide resolved
testdata/baselines/reference/submoduleAccepted/conformance/importTag17.errors.txt.diff
Show resolved
Hide resolved
No longer used; everything now uses JSImportDeclaration.
@a-tarasyuk you wrote the original implementation of |
It is slightly stricter than Strada's treatment because Corsa now treats the synthetic node exactly as a type-only declaration.