From 3170af11f2b6202a9d92fbc6be906026d80b4277 Mon Sep 17 00:00:00 2001 From: Evan You Date: Thu, 11 May 2023 08:28:20 +0100 Subject: [PATCH] fix: ignore generic attribute when generating script import close https://github.com/vuejs/core/issues/8270 --- packages/plugin-vue/src/main.ts | 11 ++++++++++- playground/vue/Main.vue | 5 ++++- playground/vue/TsGeneric.vue | 8 ++++++++ playground/vue/__tests__/vue.spec.ts | 4 ++++ 4 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 playground/vue/TsGeneric.vue diff --git a/packages/plugin-vue/src/main.ts b/packages/plugin-vue/src/main.ts index b0061012..c43886fc 100644 --- a/packages/plugin-vue/src/main.ts +++ b/packages/plugin-vue/src/main.ts @@ -486,7 +486,16 @@ async function linkSrcToDescriptor( // these are built-in query parameters so should be ignored // if the user happen to add them as attrs -const ignoreList = ['id', 'index', 'src', 'type', 'lang', 'module', 'scoped'] +const ignoreList = [ + 'id', + 'index', + 'src', + 'type', + 'lang', + 'module', + 'scoped', + 'generic', +] function attrsToQuery( attrs: SFCBlock['attrs'], diff --git a/playground/vue/Main.vue b/playground/vue/Main.vue index ce3661c7..1fbea3df 100644 --- a/playground/vue/Main.vue +++ b/playground/vue/Main.vue @@ -27,10 +27,11 @@ + + + diff --git a/playground/vue/__tests__/vue.spec.ts b/playground/vue/__tests__/vue.spec.ts index 0974fa23..c356f53f 100644 --- a/playground/vue/__tests__/vue.spec.ts +++ b/playground/vue/__tests__/vue.spec.ts @@ -323,3 +323,7 @@ describe('macro imported types', () => { ) }) }) + +test('TS with generics', async () => { + expect(await page.textContent('.generic')).toMatch('hello') +})