]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(compiler-sfc): support resolve multiple re-export /w same source type name (...
authoredison <daiwei521@126.com>
Thu, 18 May 2023 23:45:28 +0000 (07:45 +0800)
committerGitHub <noreply@github.com>
Thu, 18 May 2023 23:45:28 +0000 (07:45 +0800)
close #8364

packages/compiler-sfc/__tests__/compileScript/resolveType.spec.ts
packages/compiler-sfc/src/script/resolveType.ts

index f671541977b3e1eea6974037e14cae4b7b72d8b5..85d67e01cb8b39ba735d1d81e124df91854d74f2 100644 (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 }`,
index f4e1915255e7fc50d61c9c7e1db5f33a5bd860aa..b2e47b08beade59ee79498013f2e22941d352d93 100644 (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
                 }