]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
types: use non-null assertion instead of explicit type cast (#2974)
authorYang Mingshan <y.mingshan3@gmail.com>
Fri, 5 Feb 2021 18:55:23 +0000 (02:55 +0800)
committerGitHub <noreply@github.com>
Fri, 5 Feb 2021 18:55:23 +0000 (19:55 +0100)
packages/runtime-core/__tests__/apiInject.spec.ts

index bb21524878a5605d6f401dbdcfa1ee380c754195..f4bf2758fb03d8b02492d511e23d7451bdf56b3e 100644 (file)
@@ -139,7 +139,7 @@ describe('api: provide/inject', () => {
 
     const Consumer = {
       setup() {
-        const count = inject('count') as Ref<number>
+        const count = inject<Ref<number>>('count')!
         return () => count.value
       }
     }
@@ -169,7 +169,7 @@ describe('api: provide/inject', () => {
 
     const Consumer = {
       setup() {
-        const count = inject('count') as Ref<number>
+        const count = inject<Ref<number>>('count')!
         // should not work
         count.value++
         return () => count.value
@@ -206,7 +206,7 @@ describe('api: provide/inject', () => {
 
     const Consumer = {
       setup() {
-        const state = inject('state') as typeof rootState
+        const state = inject<typeof rootState>('state')!
         return () => state.count
       }
     }
@@ -236,7 +236,7 @@ describe('api: provide/inject', () => {
 
     const Consumer = {
       setup() {
-        const state = inject('state') as typeof rootState
+        const state = inject<typeof rootState>('state')!
         // should not work
         state.count++
         return () => state.count