Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions internal/transformers/declarations/transform.go
Original file line number Diff line number Diff line change
Expand Up @@ -571,13 +571,21 @@ func (tx *DeclarationTransformer) transformImportTypeNode(input *ast.ImportTypeN
if !ast.IsLiteralImportTypeNode(input.AsNode()) {
return input.AsNode()
}
specifier := tx.rewriteModuleSpecifier(input.AsNode(), input.Argument.AsLiteralTypeNode().Literal)
var argument *ast.Node
// Use pointer equality to check if the specifier changed - rewriteModuleSpecifier
// returns the same node instance when no rewriting is needed
if specifier == input.Argument.AsLiteralTypeNode().Literal {
// No change to the specifier, reuse the original argument to avoid creating new nodes
argument = input.Argument
} else {
// Specifier changed, create a new literal type node
argument = tx.Factory().NewLiteralTypeNode(specifier)
}
return tx.Factory().UpdateImportTypeNode(
input,
input.IsTypeOf,
tx.Factory().UpdateLiteralTypeNode(
input.Argument.AsLiteralTypeNode(),
tx.rewriteModuleSpecifier(input.AsNode(), input.Argument.AsLiteralTypeNode().Literal),
),
argument,
input.Attributes,
input.Qualifier,
tx.Visitor().VisitNodes(input.TypeArguments),
Expand Down