chore: remove deprecated defineEmit & useContext APIs

This commit is contained in:
Evan You 2021-07-16 16:56:51 -04:00
parent d4c67dd253
commit 1bab53e717
3 changed files with 0 additions and 47 deletions

View File

@ -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
} }

View File

@ -65,9 +65,6 @@ export {
// internal // internal
mergeDefaults, mergeDefaults,
withAsyncContext, withAsyncContext,
// deprecated
defineEmit,
useContext,
useAttrs, useAttrs,
useSlots useSlots
} from './apiSetupHelpers' } from './apiSetupHelpers'

View File

@ -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)