Skip to content

Commit ac1bb25

Browse files
committed
fix: import type { foo, type bar} issue
1 parent 7b1d315 commit ac1bb25

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ module.exports = function addImports(root, _statements) {
6969
decl.importKind = null
7070
}
7171
specifier.importKind = specifierImportKind
72+
} else if (
73+
decl.importKind !== 'value' &&
74+
decl.importKind === specifierImportKind
75+
) {
76+
specifier.importKind = null
7277
}
7378
decl.specifiers.push(specifier)
7479
} else {

test/index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,5 +395,16 @@ import baz from 'baz'
395395
import blah, { type qux } from "qux";
396396
`)
397397
})
398+
describe(`bugs`, function() {
399+
it(`import type { foo, type bar }`, function() {
400+
const code = `// @flow
401+
import type { foo } from 'foo'`
402+
const root = j(code)
403+
const result = addImports(root, statement`import {type bar} from 'foo'`)
404+
expect(result).to.deep.equal({ bar: 'bar' })
405+
expect(root.toSource()).to.equal(`// @flow
406+
import type { foo, bar } from 'foo';`)
407+
})
408+
})
398409
})
399410
})

0 commit comments

Comments
 (0)