11function shouldConvert ( node ) {
22 return node . importKind !== 'type'
3+ && ! hasImportAttributes ( node )
34 && node . specifiers . length > 0
45 && node . specifiers . every ( specifier => specifier . type === 'ImportSpecifier'
56 && specifier . importKind === 'type' )
@@ -28,6 +29,16 @@ function hasCommentsBetween(sourceCode, left, right) {
2829 && comment . range [ 1 ] < right . range [ 0 ] )
2930}
3031
32+ function getLocalName ( specifier ) {
33+ return specifier . local ?. name ?? null
34+ }
35+
36+ function hasOverlappingLocalNames ( left , right ) {
37+ const leftNames = new Set ( left . specifiers . map ( getLocalName ) )
38+
39+ return right . specifiers . some ( specifier => leftNames . has ( getLocalName ( specifier ) ) )
40+ }
41+
3142function canMerge ( sourceCode , typeNode , valueNode ) {
3243 return typeNode . source . value === valueNode . source . value
3344 && isTypeImport ( typeNode )
@@ -36,6 +47,7 @@ function canMerge(sourceCode, typeNode, valueNode) {
3647 && ! isTypeImport ( valueNode )
3748 && ! hasImportAttributes ( typeNode )
3849 && ! hasImportAttributes ( valueNode )
50+ && ! hasOverlappingLocalNames ( typeNode , valueNode )
3951 && ! hasCommentsBetween ( sourceCode , typeNode , valueNode )
4052}
4153
0 commit comments