vue-lynx / defineEmits

Function: defineEmits()

defineEmits(emitOptions)

function defineEmits<EE>(emitOptions): EmitFn<EE[]>

Vue <script setup> compiler macro for declaring a component's emitted events. The expected argument is the same as the component emits option.

Example runtime declaration:

const emit = defineEmits(['change', 'update'])

Example type-based declaration:

const emit = defineEmits<{
  // <eventName>: <expected arguments>
  change: []
  update: [value: number] // named tuple syntax
}>()

emit('change')
emit('update', 1)

This is only usable inside <script setup>, is compiled away in the output and should not be actually called at runtime.

Type Parameters

Type ParameterDefault type
EE extends stringstring

Parameters

ParameterType
emitOptionsEE[]

Returns

EmitFn<EE[]>

See

https://vuejs.org/api/sfc-script-setup.html#defineprops-defineemits

Defined in

node_modules/.pnpm/@vue+runtime-core@3.5.30/node_modules/@vue/runtime-core/dist/runtime-core.d.ts:226

defineEmits(emitOptions)

function defineEmits<E>(emitOptions): EmitFn<E>

Type Parameters

Type ParameterDefault type
E extends EmitsOptionsEmitsOptions

Parameters

ParameterType
emitOptionsE

Returns

EmitFn<E>

Defined in

node_modules/.pnpm/@vue+runtime-core@3.5.30/node_modules/@vue/runtime-core/dist/runtime-core.d.ts:227

defineEmits()

function defineEmits<T>(): T extends (...args) => any ? T : ShortEmits<T>

Type Parameters

Type Parameter
T extends ComponentTypeEmits

Returns

T extends (...args) => any ? T : ShortEmits<T>

Defined in

node_modules/.pnpm/@vue+runtime-core@3.5.30/node_modules/@vue/runtime-core/dist/runtime-core.d.ts:228