]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
chore: remove deprecated defineEmit & useContext APIs
authorEvan You <yyx990803@gmail.com>
Fri, 16 Jul 2021 20:56:51 +0000 (16:56 -0400)
committerEvan You <yyx990803@gmail.com>
Fri, 16 Jul 2021 20:56:51 +0000 (16:56 -0400)
packages/runtime-core/src/apiSetupHelpers.ts
packages/runtime-core/src/index.ts
test-dts/setupHelpers.test-d.ts

index 08a94f7bc310479b8d2e3871e18194d81c89f768..2c0fa241ec86e085ac79094760c664edee04e48e 100644 (file)
@@ -109,11 +109,6 @@ export function defineEmits() {
   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
@@ -178,19 +173,6 @@ export function withDefaults<Props, Defaults extends InferDefaults<Props>>(
   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
 }
index d3e211906f1f9a05e199a35325e708f961b7001a..3249f3a447dd021be75a784a2bfb26d89f187bbc 100644 (file)
@@ -65,9 +65,6 @@ export {
   // internal
   mergeDefaults,
   withAsyncContext,
-  // deprecated
-  defineEmit,
-  useContext,
   useAttrs,
   useSlots
 } from './apiSetupHelpers'
index e9a584f4145b1fa5e92f3852a36f6a5d93f04b63..1b4a2ff43ad294b63b4932c5f875092e5b4aab9c 100644 (file)
@@ -1,9 +1,7 @@
 import {
   expectType,
   defineProps,
-  defineEmit,
   defineEmits,
-  useContext,
   useAttrs,
   useSlots,
   withDefaults,
@@ -113,30 +111,6 @@ describe('defineEmits w/ runtime declaration', () => {
   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)