const onTrigger = vi.fn((e: DebuggerEvent) => {
events.push(e)
})
- const obj = reactive({ foo: 1 })
+ const obj = reactive<{ foo?: number }>({ foo: 1 })
const c = computed(() => obj.foo, { onTrigger })
// computed won't trigger compute until accessed
c.value
- obj.foo++
+ obj.foo!++
expect(c.value).toBe(2)
expect(onTrigger).toHaveBeenCalledTimes(1)
expect(events[0]).toEqual({
newValue: 2
})
- // @ts-ignore
delete obj.foo
expect(c.value).toBeUndefined()
expect(onTrigger).toHaveBeenCalledTimes(2)
const reactiveObj = reactive(obj)
expect(isReactive(reactiveObj)).toBe(true)
// read prop of reactiveObject will cause reactiveObj[prop] to be reactive
- // @ts-ignore
+ // @ts-expect-error
const prototype = reactiveObj['__proto__']
const otherObj = { data: ['a'] }
expect(isReactive(otherObj)).toBe(false)
const dummy = computed(() => observed.a)
expect(dummy.value).toBe(0)
- // @ts-ignore
+ // @ts-expect-error
observed.a = bar
expect(dummy.value).toBe(1)