Skip to content

Commit 9f25af2

Browse files
Port PR#61261: Fixed accidentally reused comments between files in the emitter
Co-authored-by: RyanCavanaugh <[email protected]>
1 parent 4656101 commit 9f25af2

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

internal/transformers/declarations/transform.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -571,13 +571,19 @@ func (tx *DeclarationTransformer) transformImportTypeNode(input *ast.ImportTypeN
571571
if !ast.IsLiteralImportTypeNode(input.AsNode()) {
572572
return input.AsNode()
573573
}
574+
specifier := tx.rewriteModuleSpecifier(input.AsNode(), input.Argument.AsLiteralTypeNode().Literal)
575+
var argument *ast.Node
576+
if specifier == input.Argument.AsLiteralTypeNode().Literal {
577+
// No change to the specifier, reuse the original argument to avoid creating new nodes
578+
argument = input.Argument
579+
} else {
580+
// Specifier changed, create a new literal type node
581+
argument = tx.Factory().NewLiteralTypeNode(specifier)
582+
}
574583
return tx.Factory().UpdateImportTypeNode(
575584
input,
576585
input.IsTypeOf,
577-
tx.Factory().UpdateLiteralTypeNode(
578-
input.Argument.AsLiteralTypeNode(),
579-
tx.rewriteModuleSpecifier(input.AsNode(), input.Argument.AsLiteralTypeNode().Literal),
580-
),
586+
argument,
581587
input.Attributes,
582588
input.Qualifier,
583589
tx.Visitor().VisitNodes(input.TypeArguments),

0 commit comments

Comments
 (0)