Skip to content

Commit 06a2c64

Browse files
authored
Merge pull request #11 from nathanwhit/raw-imports-nil
fix: check for nil
2 parents d82156d + 6110618 commit 06a2c64

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

internal/compiler/fileloader.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -790,12 +790,16 @@ func getModuleLiteralImportKind(node *ast.StringLiteralLike) *string {
790790
}
791791

792792
if ast.IsImportDeclaration(parent) || ast.IsExportDeclaration(parent) {
793-
var elements []*ast.Node
793+
var attrs *ast.ImportAttributesNode
794794
if ast.IsImportDeclaration(parent) {
795-
elements = parent.AsImportDeclaration().Attributes.AsImportAttributes().Attributes.Nodes
795+
attrs = parent.AsImportDeclaration().Attributes
796796
} else {
797-
elements = parent.AsExportDeclaration().Attributes.AsImportAttributes().Attributes.Nodes
797+
attrs = parent.AsExportDeclaration().Attributes
798798
}
799+
if attrs == nil {
800+
return nil
801+
}
802+
elements := attrs.AsImportAttributes().Attributes.Nodes
799803
if elements == nil {
800804
return nil
801805
}

0 commit comments

Comments
 (0)