Skip to content

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

sandersn
Copy link
Member

It is slightly stricter than Strada's treatment because Corsa now treats the synthetic node exactly as a type-only declaration.

It is slightly stricter than Strada's treatment because Corsa now treats
the synthetic node *exactly* as a type-only declaration.
@Copilot Copilot AI review requested due to automatic review settings April 28, 2025 15:21
Copy link
Contributor

@Copilot Copilot AI left a 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

No longer used; everything now uses JSImportDeclaration.
@sandersn
Copy link
Member Author

@a-tarasyuk you wrote the original implementation of @import, so you might be interested to see how it looks in Corsa.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants