Skip to content

Commit fb320fb

Browse files
committed
fix: correct process property names in imports
fix #316
1 parent 5652490 commit fb320fb

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

examples/react/src/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import HelloWorld from './components/HelloWorld'
22

3+
import type { ReactDOM as MyReactDOM } from 'react'
4+
35
export { HelloWorld }
46
export { default as App } from './App'
57
export * from './modules'
8+
9+
export function test(dom: MyReactDOM) {}

examples/ts/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ export { ParametersTest, test, method } from './test'
1717
export { data }
1818
export default data
1919

20-
export type { User } from './types'
20+
export type { User as MyUser } from './types'
2121
export type { AliasType } from '@alias/type'

src/transform.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,11 @@ export function transformCode(options: {
126126

127127
if (node.importClause.namedBindings && ts.isNamedImports(node.importClause.namedBindings)) {
128128
node.importClause.namedBindings.elements.forEach(element => {
129-
importSet.add(element.name.escapedText as string)
129+
if (element.propertyName) {
130+
importSet.add(`${element.propertyName.escapedText} as ${element.name.escapedText}`)
131+
} else {
132+
importSet.add(element.name.escapedText as string)
133+
}
130134
})
131135
}
132136

0 commit comments

Comments
 (0)