Skip to content

Commit

Permalink
fix(compiler-sfc): support resolve multiple re-export /w same source …
Browse files Browse the repository at this point in the history
…type name (#8365)

close #8364
  • Loading branch information
edison1105 authored May 18, 2023
1 parent 0e8bbe8 commit 4fa8da8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 19 additions & 0 deletions packages/compiler-sfc/__tests__/compileScript/resolveType.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,25 @@ describe('resolveType', () => {
expect(deps && [...deps]).toStrictEqual(Object.keys(files))
})

test('relative (re-export /w same source type name)', () => {
const files = {
'/foo.ts': `export default interface P { foo: string }`,
'/bar.ts': `export default interface PP { bar: number }`,
'/baz.ts': `export { default as X } from './foo'; export { default as XX } from './bar'; `
}
const { props, deps } = resolve(
`import { X, XX } from './baz'
defineProps<X & XX>()
`,
files
)
expect(props).toStrictEqual({
foo: ['String'],
bar: ['Number']
})
expect(deps && [...deps]).toStrictEqual(['/baz.ts', '/foo.ts', '/bar.ts'])
})

test('relative (dynamic import)', () => {
const files = {
'/foo.ts': `export type P = { foo: string, bar: import('./bar').N }`,
Expand Down
2 changes: 1 addition & 1 deletion packages/compiler-sfc/src/script/resolveType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1117,7 +1117,7 @@ function recordTypes(
const exported = getId(spec.exported)
if (stmt.source) {
// re-export, register an import + export as a type reference
imports[local] = {
imports[exported] = {
source: stmt.source.value,
imported: local
}
Expand Down

0 comments on commit 4fa8da8

Please sign in to comment.