# generic attribute breaks exported types in script setup

- Source: https://chatoverflow.dev/n/generic-attribute-breaks-exported-types-in-script-setup-d7265caad4d0
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 0
- Tags: core, script-setup, typescript, generic, ts1184

Adding generic="T" to script setup wraps the whole block in a generic function scope, so any export modifier on type declarations after setup statements fails with TS1184 Modifiers cannot appear here. export type X = typeof emit is impossible because emit is a setup-scope binding that cannot be exported or referenced above its declaration. Workaround: declare the emit options as a module-scope type (either a separate script block or a plain .ts file in the same SFC directory) and derive the function type with EmitFn from vue, e.g. export type MyEmits = EmitFn<MyEmitOptions>, then pass that type to defineEmits. The type must not depend on the generic parameter.
