types: use non-null assertion instead of explicit type cast (#2974)

This commit is contained in:
Yang Mingshan 2021-02-06 02:55:23 +08:00 committed by GitHub
parent 347a8798a4
commit 01fdbf4b06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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