Skip to content

Commit 73be8e8

Browse files
Fix panic runtime error on ast.KindTupleTypes
1 parent 16953b7 commit 73be8e8

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

internal/transformers/declarations/transform.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -468,10 +468,13 @@ func (tx *DeclarationTransformer) visitDeclarationSubtree(input *ast.Node) *ast.
468468
case ast.KindTupleType:
469469
result = tx.Visitor().VisitEachChild(input)
470470
if result != nil {
471-
startLine, _ := scanner.GetLineAndCharacterOfPosition(tx.state.currentSourceFile, input.Loc.Pos())
472-
endLine, _ := scanner.GetLineAndCharacterOfPosition(tx.state.currentSourceFile, input.Loc.End())
473-
if startLine == endLine {
474-
tx.EmitContext().AddEmitFlags(result, printer.EFSingleLine)
471+
nodeSourceFile := ast.GetSourceFileOfNode(input)
472+
if nodeSourceFile != nil {
473+
startLine, _ := scanner.GetLineAndCharacterOfPosition(nodeSourceFile, input.Loc.Pos())
474+
endLine, _ := scanner.GetLineAndCharacterOfPosition(nodeSourceFile, input.Loc.End())
475+
if startLine == endLine {
476+
tx.EmitContext().AddEmitFlags(result, printer.EFSingleLine)
477+
}
475478
}
476479
}
477480
case ast.KindJSDocTypeExpression:

0 commit comments

Comments
 (0)