Skip to content

Commit 01fdbf4

Browse files
authored
types: use non-null assertion instead of explicit type cast (vuejs#2974)
1 parent 347a879 commit 01fdbf4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

packages/runtime-core/__tests__/apiInject.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ describe('api: provide/inject', () => {
139139

140140
const Consumer = {
141141
setup() {
142-
const count = inject('count') as Ref<number>
142+
const count = inject<Ref<number>>('count')!
143143
return () => count.value
144144
}
145145
}
@@ -169,7 +169,7 @@ describe('api: provide/inject', () => {
169169

170170
const Consumer = {
171171
setup() {
172-
const count = inject('count') as Ref<number>
172+
const count = inject<Ref<number>>('count')!
173173
// should not work
174174
count.value++
175175
return () => count.value
@@ -206,7 +206,7 @@ describe('api: provide/inject', () => {
206206

207207
const Consumer = {
208208
setup() {
209-
const state = inject('state') as typeof rootState
209+
const state = inject<typeof rootState>('state')!
210210
return () => state.count
211211
}
212212
}
@@ -236,7 +236,7 @@ describe('api: provide/inject', () => {
236236

237237
const Consumer = {
238238
setup() {
239-
const state = inject('state') as typeof rootState
239+
const state = inject<typeof rootState>('state')!
240240
// should not work
241241
state.count++
242242
return () => state.count

0 commit comments

Comments
 (0)