Skip to content

Commit c62a410

Browse files
committed
address PR feedback
1 parent 2c010fc commit c62a410

File tree

3 files changed

+6
-10
lines changed

3 files changed

+6
-10
lines changed

internal/ast/utilities.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2847,13 +2847,11 @@ func GetLeftmostAccessExpression(expr *Node) *Node {
28472847
func IsTypeOnlyImportDeclaration(node *Node) bool {
28482848
switch node.Kind {
28492849
case KindImportSpecifier:
2850-
return node.AsImportSpecifier().IsTypeOnly || node.Parent.Parent.AsImportClause().PhaseModifier == KindTypeKeyword
2850+
return node.IsTypeOnly() || node.Parent.Parent.IsTypeOnly()
28512851
case KindNamespaceImport:
2852-
return node.Parent.AsImportClause().PhaseModifier == KindTypeKeyword
2853-
case KindImportClause:
2854-
return node.AsImportClause().PhaseModifier == KindTypeKeyword
2855-
case KindImportEqualsDeclaration:
2856-
return node.AsImportEqualsDeclaration().IsTypeOnly
2852+
return node.Parent.IsTypeOnly()
2853+
case KindImportClause, KindImportEqualsDeclaration:
2854+
return node.IsTypeOnly()
28572855
}
28582856
return false
28592857
}

internal/ls/autoimportfixes.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func (ct *changeTracker) doAddExistingFix(
8989
identifier = ct.NodeFactory.NewIdentifier(namedImport.propertyName).AsIdentifier().AsNode()
9090
}
9191
return ct.NodeFactory.NewImportSpecifier(
92-
(importClause.PhaseModifier != ast.KindTypeKeyword || promoteFromTypeOnly) && shouldUseTypeOnly(namedImport.addAsTypeOnly, preferences),
92+
(!importClause.IsTypeOnly() || promoteFromTypeOnly) && shouldUseTypeOnly(namedImport.addAsTypeOnly, preferences),
9393
identifier,
9494
ct.NodeFactory.NewIdentifier(namedImport.name),
9595
)

internal/parser/parser.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2112,9 +2112,7 @@ func (p *Parser) parseImportDeclarationOrImportEqualsDeclaration(pos int, hasJSD
21122112
} else if identifier != nil && identifier.AsIdentifier().Text == "defer" {
21132113
var shouldParseAsDeferModifier bool
21142114
if p.token == ast.KindFromKeyword {
2115-
shouldParseAsDeferModifier = !p.lookAhead(func(p *Parser) bool {
2116-
return p.nextTokenIsTokenStringLiteral()
2117-
})
2115+
shouldParseAsDeferModifier = !p.lookAhead((*Parser).nextTokenIsTokenStringLiteral)
21182116
} else {
21192117
shouldParseAsDeferModifier = p.token != ast.KindCommaToken && p.token != ast.KindEqualsToken
21202118
}

0 commit comments

Comments
 (0)