Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix: ignore generic attribute when generating script import
  • Loading branch information
yyx990803 committed May 11, 2023
1 parent ffe74e5 commit 3170af1
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
11 changes: 10 additions & 1 deletion packages/plugin-vue/src/main.ts
Expand Up @@ -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'],
Expand Down
5 changes: 4 additions & 1 deletion playground/vue/Main.vue
Expand Up @@ -27,10 +27,11 @@
<SetupImportTemplate />
<WorkerTest />
<Url />
<TsGeneric msg="hello" />
</template>

<script setup lang="ts">
import { version } from 'vue'
import { version, defineAsyncComponent } from 'vue'
import Hmr from './Hmr.vue'
import HmrTsx from './HmrTsx.vue'
import Syntax from './Syntax.vue'
Expand All @@ -50,6 +51,8 @@ import { ref } from 'vue'
import Url from './Url.vue'
import TypeProps from './TypeProps.vue'
const TsGeneric = defineAsyncComponent(() => import('./TsGeneric.vue'))
const time = ref('loading...')
window.addEventListener('load', () => {
Expand Down
8 changes: 8 additions & 0 deletions playground/vue/TsGeneric.vue
@@ -0,0 +1,8 @@
<script setup lang="ts" generic="T extends string">
defineProps<{ msg: T }>()
</script>

<template>
<h2>TS with Generics</h2>
<div class="generic">{{ msg }}</div>
</template>
4 changes: 4 additions & 0 deletions playground/vue/__tests__/vue.spec.ts
Expand Up @@ -323,3 +323,7 @@ describe('macro imported types', () => {
)
})
})

test('TS with generics', async () => {
expect(await page.textContent('.generic')).toMatch('hello')
})

0 comments on commit 3170af1

Please sign in to comment.