const Consumer = {
setup() {
- const count = inject('count') as Ref<number>
+ const count = inject<Ref<number>>('count')!
return () => count.value
}
}
const Consumer = {
setup() {
- const count = inject('count') as Ref<number>
+ const count = inject<Ref<number>>('count')!
// should not work
count.value++
return () => count.value
const Consumer = {
setup() {
- const state = inject('state') as typeof rootState
+ const state = inject<typeof rootState>('state')!
return () => state.count
}
}
const Consumer = {
setup() {
- const state = inject('state') as typeof rootState
+ const state = inject<typeof rootState>('state')!
// should not work
state.count++
return () => state.count