Преглед на файлове

chore(types): remove unnecessary @ts-ignore or use @ts-expected-error (#7178)

преди 2 години
родител
ревизия
b401243855
променени са 2 файла, в които са добавени 4 реда и са изтрити 5 реда
  1. 2 3
      packages/reactivity/__tests__/computed.spec.ts
  2. 2 2
      packages/reactivity/__tests__/reactive.spec.ts

+ 2 - 3
packages/reactivity/__tests__/computed.spec.ts

@@ -259,13 +259,13 @@ describe('reactivity/computed', () => {
     const onTrigger = vi.fn((e: DebuggerEvent) => {
     const onTrigger = vi.fn((e: DebuggerEvent) => {
       events.push(e)
       events.push(e)
     })
     })
-    const obj = reactive({ foo: 1 })
+    const obj = reactive<{ foo?: number }>({ foo: 1 })
     const c = computed(() => obj.foo, { onTrigger })
     const c = computed(() => obj.foo, { onTrigger })
 
 
     // computed won't trigger compute until accessed
     // computed won't trigger compute until accessed
     c.value
     c.value
 
 
-    obj.foo++
+    obj.foo!++
     expect(c.value).toBe(2)
     expect(c.value).toBe(2)
     expect(onTrigger).toHaveBeenCalledTimes(1)
     expect(onTrigger).toHaveBeenCalledTimes(1)
     expect(events[0]).toEqual({
     expect(events[0]).toEqual({
@@ -277,7 +277,6 @@ describe('reactivity/computed', () => {
       newValue: 2
       newValue: 2
     })
     })
 
 
-    // @ts-ignore
     delete obj.foo
     delete obj.foo
     expect(c.value).toBeUndefined()
     expect(c.value).toBeUndefined()
     expect(onTrigger).toHaveBeenCalledTimes(2)
     expect(onTrigger).toHaveBeenCalledTimes(2)

+ 2 - 2
packages/reactivity/__tests__/reactive.spec.ts

@@ -23,7 +23,7 @@ describe('reactivity/reactive', () => {
     const reactiveObj = reactive(obj)
     const reactiveObj = reactive(obj)
     expect(isReactive(reactiveObj)).toBe(true)
     expect(isReactive(reactiveObj)).toBe(true)
     // read prop of reactiveObject will cause reactiveObj[prop] to be reactive
     // read prop of reactiveObject will cause reactiveObj[prop] to be reactive
-    // @ts-ignore
+    // @ts-expect-error
     const prototype = reactiveObj['__proto__']
     const prototype = reactiveObj['__proto__']
     const otherObj = { data: ['a'] }
     const otherObj = { data: ['a'] }
     expect(isReactive(otherObj)).toBe(false)
     expect(isReactive(otherObj)).toBe(false)
@@ -204,7 +204,7 @@ describe('reactivity/reactive', () => {
     const dummy = computed(() => observed.a)
     const dummy = computed(() => observed.a)
     expect(dummy.value).toBe(0)
     expect(dummy.value).toBe(0)
 
 
-    // @ts-ignore
+    // @ts-expect-error
     observed.a = bar
     observed.a = bar
     expect(dummy.value).toBe(1)
     expect(dummy.value).toBe(1)