chore: remove deprecated defineEmit & useContext APIs
This commit is contained in:
parent
d4c67dd253
commit
1bab53e717
@ -109,11 +109,6 @@ export function defineEmits() {
|
|||||||
return null as any
|
return null as any
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated use `defineEmits` instead.
|
|
||||||
*/
|
|
||||||
export const defineEmit = defineEmits
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Vue `<script setup>` compiler macro for declaring a component's exposed
|
* Vue `<script setup>` compiler macro for declaring a component's exposed
|
||||||
* instance properties when it is accessed by a parent component via template
|
* instance properties when it is accessed by a parent component via template
|
||||||
@ -178,19 +173,6 @@ export function withDefaults<Props, Defaults extends InferDefaults<Props>>(
|
|||||||
return null as any
|
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'] {
|
export function useSlots(): SetupContext['slots'] {
|
||||||
return getContext().slots
|
return getContext().slots
|
||||||
}
|
}
|
||||||
|
@ -65,9 +65,6 @@ export {
|
|||||||
// internal
|
// internal
|
||||||
mergeDefaults,
|
mergeDefaults,
|
||||||
withAsyncContext,
|
withAsyncContext,
|
||||||
// deprecated
|
|
||||||
defineEmit,
|
|
||||||
useContext,
|
|
||||||
useAttrs,
|
useAttrs,
|
||||||
useSlots
|
useSlots
|
||||||
} from './apiSetupHelpers'
|
} from './apiSetupHelpers'
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
import {
|
import {
|
||||||
expectType,
|
expectType,
|
||||||
defineProps,
|
defineProps,
|
||||||
defineEmit,
|
|
||||||
defineEmits,
|
defineEmits,
|
||||||
useContext,
|
|
||||||
useAttrs,
|
useAttrs,
|
||||||
useSlots,
|
useSlots,
|
||||||
withDefaults,
|
withDefaults,
|
||||||
@ -113,30 +111,6 @@ describe('defineEmits w/ runtime declaration', () => {
|
|||||||
emit2('baz')
|
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', () => {
|
describe('useAttrs', () => {
|
||||||
const attrs = useAttrs()
|
const attrs = useAttrs()
|
||||||
expectType<Record<string, unknown>>(attrs)
|
expectType<Record<string, unknown>>(attrs)
|
||||||
|
Loading…
Reference in New Issue
Block a user