return null as any
}
-/**
- * @deprecated use `defineEmits` instead.
- */
-export const defineEmit = defineEmits
-
/**
* Vue `<script setup>` compiler macro for declaring a component's exposed
* instance properties when it is accessed by a parent component via template
return null as any
}
-/**
- * @deprecated use `useSlots` and `useAttrs` instead.
- */
-export function useContext(): SetupContext {
- if (__DEV__) {
- warn(
- `\`useContext()\` has been deprecated and will be removed in the ` +
- `next minor release. Use \`useSlots()\` and \`useAttrs()\` instead.`
- )
- }
- return getContext()
-}
-
export function useSlots(): SetupContext['slots'] {
return getContext().slots
}
import {
expectType,
defineProps,
- defineEmit,
defineEmits,
- useContext,
useAttrs,
useSlots,
withDefaults,
emit2('baz')
})
-describe('deprecated defineEmit', () => {
- const emit = defineEmit({
- foo: () => {},
- bar: null
- })
- emit('foo')
- emit('bar', 123)
- // @ts-expect-error
- emit('baz')
-})
-
-describe('useContext', () => {
- const { attrs, emit, slots } = useContext()
- expectType<Record<string, unknown>>(attrs)
- expectType<(...args: any[]) => void>(emit)
- expectType<Slots>(slots)
-
- // @ts-expect-error
- props.foo
- // should be able to emit anything
- emit('foo')
- emit('bar')
-})
-
describe('useAttrs', () => {
const attrs = useAttrs()
expectType<Record<string, unknown>>(attrs)