fix(compiler-sfc): support resolve multiple re-export /w same source type name (#8365)

close #8364
This commit is contained in:
edison 2023-05-19 07:45:28 +08:00 committed by GitHub
parent 0e8bbe873e
commit 4fa8da8576
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 1 deletions

View File

@ -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 }`,

View File

@ -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
}