Skip to content

Commit

Permalink
fix: correct process property names in imports
Browse files Browse the repository at this point in the history
fix #316
  • Loading branch information
qmhc committed Mar 28, 2024
1 parent 5652490 commit fb320fb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions examples/react/src/index.ts
@@ -1,5 +1,9 @@
import HelloWorld from './components/HelloWorld'

import type { ReactDOM as MyReactDOM } from 'react'

export { HelloWorld }
export { default as App } from './App'
export * from './modules'

export function test(dom: MyReactDOM) {}
2 changes: 1 addition & 1 deletion examples/ts/src/index.ts
Expand Up @@ -17,5 +17,5 @@ export { ParametersTest, test, method } from './test'
export { data }
export default data

export type { User } from './types'
export type { User as MyUser } from './types'
export type { AliasType } from '@alias/type'
6 changes: 5 additions & 1 deletion src/transform.ts
Expand Up @@ -126,7 +126,11 @@ export function transformCode(options: {

if (node.importClause.namedBindings && ts.isNamedImports(node.importClause.namedBindings)) {
node.importClause.namedBindings.elements.forEach(element => {
importSet.add(element.name.escapedText as string)
if (element.propertyName) {
importSet.add(`${element.propertyName.escapedText} as ${element.name.escapedText}`)
} else {
importSet.add(element.name.escapedText as string)
}
})
}

Expand Down

0 comments on commit fb320fb

Please sign in to comment.