feat(sfc): add defineEmits and deprecate defineEmit (#3725)
This commit is contained in:
committed by
GitHub
parent
6b6d566861
commit
a137da8a9f
@@ -38,17 +38,17 @@ export function defineProps() {
|
||||
return null as any
|
||||
}
|
||||
|
||||
export function defineEmit<
|
||||
export function defineEmits<
|
||||
TypeEmit = undefined,
|
||||
E extends EmitsOptions = EmitsOptions,
|
||||
EE extends string = string,
|
||||
InferredEmit = EmitFn<E>
|
||||
>(emitOptions?: E | EE[]): TypeEmit extends undefined ? InferredEmit : TypeEmit
|
||||
// implementation
|
||||
export function defineEmit() {
|
||||
export function defineEmits() {
|
||||
if (__DEV__) {
|
||||
warn(
|
||||
`defineEmit() is a compiler-hint helper that is only usable inside ` +
|
||||
`defineEmits() is a compiler-hint helper that is only usable inside ` +
|
||||
`<script setup> of a single file component. Its arguments should be ` +
|
||||
`compiled away and passing it at runtime has no effect.`
|
||||
)
|
||||
@@ -56,6 +56,11 @@ export function defineEmit() {
|
||||
return null as any
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use `defineEmits` instead.
|
||||
*/
|
||||
export const defineEmit = defineEmits
|
||||
|
||||
export function useContext(): SetupContext {
|
||||
const i = getCurrentInstance()!
|
||||
if (__DEV__ && !i) {
|
||||
|
||||
@@ -44,7 +44,12 @@ export { provide, inject } from './apiInject'
|
||||
export { nextTick } from './scheduler'
|
||||
export { defineComponent } from './apiDefineComponent'
|
||||
export { defineAsyncComponent } from './apiAsyncComponent'
|
||||
export { defineProps, defineEmit, useContext } from './apiSetupHelpers'
|
||||
export {
|
||||
defineProps,
|
||||
defineEmits,
|
||||
defineEmit,
|
||||
useContext
|
||||
} from './apiSetupHelpers'
|
||||
|
||||
// Advanced API ----------------------------------------------------------------
|
||||
|
||||
|
||||
Reference in New Issue
Block a user