Open
Description
Vue version
3.5.16
Link to minimal reproduction
https://github.com/alexchexes/vue-test-generic-export/blob/master/src/App.vue
Steps to reproduce
- Add
generic="T"
attribute to the<script setup>
(<script setup lang="ts" generic="T">
) - Add a type export, e.g.
export type MyType = 123
, within that script setup scope - Observe the
Modifiers cannot appear here. ts(1184)
TypeScript error in VSCode - Remove
generic="T"
and the error disappears, confirming the issue is related to thegeneric="T"
attribute
Reproduction:
<script setup lang="ts" generic="T">
defineProps<{
items: string[]
selected: string
}>()
export type MyType = 123 // ← TS Error: Modifiers cannot appear here. ts(1184)
</script>
What is expected?
No error should occur when exporting types after adding generic="T"
to <script setup>
What is actually happening?
A Modifiers cannot appear here. ts(1184)
TypeScript error appears as soon as generic="T"
is added to <script setup>
, but no error occurs when it is removed
System Info
System:
OS: Windows 11 10.0.26100
CPU: (20) x64 12th Gen Intel(R) Core(TM) i7-12700H
Memory: 32.97 GB / 63.67 GB
Binaries:
Node: 22.11.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.22 - ~\AppData\Roaming\npm\yarn.CMD
npm: 10.9.0 - C:\Program Files\nodejs\npm.CMD
pnpm: 9.12.3 - ~\AppData\Roaming\npm\pnpm.CMD
Browsers:
Edge: Chromium (130.0.2849.80)
npmPackages:
vue: ^3.5.13 => 3.5.16
Any additional comments?
If this is a restriction of generic components, we should mention it in the generics section of the <script setup>
docs