]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
chore(types): delete @ts-ignore or use @ts-expected-error instead (#3669)
authorHeYunfei <i.heyunfei@gmail.com>
Thu, 12 May 2022 00:40:59 +0000 (08:40 +0800)
committerGitHub <noreply@github.com>
Thu, 12 May 2022 00:40:59 +0000 (20:40 -0400)
Co-authored-by: heyunfei.i <heyunfei.i@bytedance.com>
packages/reactivity/__tests__/effect.spec.ts
packages/reactivity/__tests__/reactiveArray.spec.ts
packages/reactivity/__tests__/readonly.spec.ts
packages/reactivity/__tests__/shallowReadonly.spec.ts
packages/runtime-core/__tests__/apiLifecycle.spec.ts
packages/runtime-core/__tests__/apiOptions.spec.ts
packages/runtime-core/__tests__/apiWatch.spec.ts
packages/runtime-core/__tests__/componentEmits.spec.ts

index 34b9c575c93306a0f3737fef00fbcd97ebf827b9..a66aff278a4eeca3c54b50c021f767685c36ce62 100644 (file)
@@ -66,22 +66,22 @@ describe('reactivity/effect', () => {
 
   it('should observe delete operations', () => {
     let dummy
-    const obj = reactive({ prop: 'value' })
+    const obj = reactive<{
+      prop?: string
+    }>({ prop: 'value' })
     effect(() => (dummy = obj.prop))
 
     expect(dummy).toBe('value')
-    // @ts-ignore
     delete obj.prop
     expect(dummy).toBe(undefined)
   })
 
   it('should observe has operations', () => {
     let dummy
-    const obj = reactive<{ prop: string | number }>({ prop: 'value' })
+    const obj = reactive<{ prop?: string | number }>({ prop: 'value' })
     effect(() => (dummy = 'prop' in obj))
 
     expect(dummy).toBe(true)
-    // @ts-ignore
     delete obj.prop
     expect(dummy).toBe(false)
     obj.prop = 12
@@ -90,13 +90,12 @@ describe('reactivity/effect', () => {
 
   it('should observe properties on the prototype chain', () => {
     let dummy
-    const counter = reactive({ num: 0 })
+    const counter = reactive<{ num?: number }>({ num: 0 })
     const parentCounter = reactive({ num: 2 })
     Object.setPrototypeOf(counter, parentCounter)
     effect(() => (dummy = counter.num))
 
     expect(dummy).toBe(0)
-    // @ts-ignore
     delete counter.num
     expect(dummy).toBe(2)
     parentCounter.num = 4
@@ -107,16 +106,14 @@ describe('reactivity/effect', () => {
 
   it('should observe has operations on the prototype chain', () => {
     let dummy
-    const counter = reactive({ num: 0 })
-    const parentCounter = reactive({ num: 2 })
+    const counter = reactive<{ num?: number }>({ num: 0 })
+    const parentCounter = reactive<{ num?: number }>({ num: 2 })
     Object.setPrototypeOf(counter, parentCounter)
     effect(() => (dummy = 'num' in counter))
 
     expect(dummy).toBe(true)
-    // @ts-ignore
     delete counter.num
     expect(dummy).toBe(true)
-    // @ts-ignore
     delete parentCounter.num
     expect(dummy).toBe(false)
     counter.num = 3
@@ -220,7 +217,7 @@ describe('reactivity/effect', () => {
   it('should observe symbol keyed properties', () => {
     const key = Symbol('symbol keyed prop')
     let dummy, hasDummy
-    const obj = reactive({ [key]: 'value' })
+    const obj = reactive<{ [key]?: string }>({ [key]: 'value' })
     effect(() => (dummy = obj[key]))
     effect(() => (hasDummy = key in obj))
 
@@ -228,7 +225,6 @@ describe('reactivity/effect', () => {
     expect(hasDummy).toBe(true)
     obj[key] = 'newValue'
     expect(dummy).toBe('newValue')
-    // @ts-ignore
     delete obj[key]
     expect(dummy).toBe(undefined)
     expect(hasDummy).toBe(false)
@@ -752,7 +748,7 @@ describe('reactivity/effect', () => {
     const onTrigger = jest.fn((e: DebuggerEvent) => {
       events.push(e)
     })
-    const obj = reactive({ foo: 1 })
+    const obj = reactive<{ foo?: number }>({ foo: 1 })
     const runner = effect(
       () => {
         dummy = obj.foo
@@ -760,7 +756,7 @@ describe('reactivity/effect', () => {
       { onTrigger }
     )
 
-    obj.foo++
+    obj.foo!++
     expect(dummy).toBe(2)
     expect(onTrigger).toHaveBeenCalledTimes(1)
     expect(events[0]).toEqual({
@@ -772,7 +768,6 @@ describe('reactivity/effect', () => {
       newValue: 2
     })
 
-    // @ts-ignore
     delete obj.foo
     expect(dummy).toBeUndefined()
     expect(onTrigger).toHaveBeenCalledTimes(2)
index 9402f3c5d6ebedd394ba2e8a023a7c0dc450998c..1b7323fa97e0e5eb248ebc7cf3233ac5172e6839 100644 (file)
@@ -112,14 +112,13 @@ describe('reactivity/reactive/Array', () => {
   })
 
   test('add non-integer prop on Array should not trigger length dependency', () => {
-    const array = new Array(3)
+    const array: any[] & { x?: string } = new Array(3)
     const observed = reactive(array)
     const fn = jest.fn()
     effect(() => {
       fn(observed.length)
     })
     expect(fn).toHaveBeenCalledTimes(1)
-    // @ts-ignore
     observed.x = 'x'
     expect(fn).toHaveBeenCalledTimes(1)
     observed[-1] = 'x'
index 3d597de6615820923e8b770a3e5795b91456dc57..c37c8e190ed39b2a6e1463c1371f6fc57cd574dc 100644 (file)
@@ -68,21 +68,21 @@ describe('reactivity/readonly', () => {
         `Set operation on key "Symbol(qux)" failed: target is readonly.`
       ).toHaveBeenWarnedLast()
 
-      // @ts-ignore
+      // @ts-expect-error
       delete wrapped.foo
       expect(wrapped.foo).toBe(1)
       expect(
         `Delete operation on key "foo" failed: target is readonly.`
       ).toHaveBeenWarnedLast()
 
-      // @ts-ignore
+      // @ts-expect-error
       delete wrapped.bar.baz
       expect(wrapped.bar.baz).toBe(2)
       expect(
         `Delete operation on key "baz" failed: target is readonly.`
       ).toHaveBeenWarnedLast()
 
-      // @ts-ignore
+      // @ts-expect-error
       delete wrapped[qux]
       expect(wrapped[qux]).toBe(3)
       expect(
index ca3f9671c59b62904f2f2b9a9196e4b1c42bf9ee..79d4376cc015de26740a4de0cb26064d946533b3 100644 (file)
@@ -8,7 +8,7 @@ describe('reactivity/shallowReadonly', () => {
 
   test('should make root level properties readonly', () => {
     const props = shallowReadonly({ n: 1 })
-    // @ts-ignore
+    // @ts-expect-error
     props.n = 2
     expect(props.n).toBe(1)
     expect(
@@ -19,7 +19,7 @@ describe('reactivity/shallowReadonly', () => {
   // to retain 2.x behavior.
   test('should NOT make nested properties readonly', () => {
     const props = shallowReadonly({ n: { foo: 1 } })
-    // @ts-ignore
+
     props.n.foo = 2
     expect(props.n.foo).toBe(2)
     expect(
index d8ce5b3edfe0544f2a903c91ab0324ac0afac121..60a7f7d0cce3540f650d5a62f255c431225bbd2a 100644 (file)
@@ -334,7 +334,10 @@ describe('api: lifecycle hooks', () => {
     const onTrigger = jest.fn((e: DebuggerEvent) => {
       events.push(e)
     })
-    const obj = reactive({ foo: 1, bar: 2 })
+    const obj = reactive<{
+      foo: number
+      bar?: number
+    }>({ foo: 1, bar: 2 })
 
     const Comp = {
       setup() {
@@ -356,7 +359,6 @@ describe('api: lifecycle hooks', () => {
       newValue: 2
     })
 
-    // @ts-ignore
     delete obj.bar
     await nextTick()
     expect(onTrigger).toHaveBeenCalledTimes(2)
index 0dda642656541c1a1894dfadabc8eec5ad4fe8a8..18207f61dc37a75b668acad0adaac5e3aa3f460e 100644 (file)
@@ -1411,7 +1411,7 @@ describe('api: options', () => {
       }
 
       const root = nodeOps.createElement('div')
-      // @ts-ignore
+      // @ts-expect-error
       render(h(Comp), root)
 
       expect('Invalid watch option: "foo"').toHaveBeenWarned()
index 572ac11d163c009c3402af2d9111c1498df86b95..1c6fb0a88df8321a188eca64f87378d09169ca7c 100644 (file)
@@ -214,7 +214,7 @@ describe('api: watch', () => {
   })
 
   it('warn invalid watch source', () => {
-    // @ts-ignore
+    // @ts-expect-error
     watch(1, () => {})
     expect(`Invalid watch source`).toHaveBeenWarned()
   })
@@ -748,7 +748,7 @@ describe('api: watch', () => {
       () => {
         dummy = count.value
       },
-      // @ts-ignore
+      // @ts-expect-error
       { immediate: false }
     )
     expect(dummy).toBe(0)
@@ -767,7 +767,7 @@ describe('api: watch', () => {
         spy()
         return arr
       },
-      // @ts-ignore
+      // @ts-expect-error
       { deep: true }
     )
     expect(spy).toHaveBeenCalledTimes(1)
@@ -818,7 +818,7 @@ describe('api: watch', () => {
     const onTrigger = jest.fn((e: DebuggerEvent) => {
       events.push(e)
     })
-    const obj = reactive({ foo: 1 })
+    const obj = reactive<{ foo?: number }>({ foo: 1 })
     watchEffect(
       () => {
         dummy = obj.foo
@@ -828,7 +828,7 @@ describe('api: watch', () => {
     await nextTick()
     expect(dummy).toBe(1)
 
-    obj.foo++
+    obj.foo!++
     await nextTick()
     expect(dummy).toBe(2)
     expect(onTrigger).toHaveBeenCalledTimes(1)
@@ -839,7 +839,6 @@ describe('api: watch', () => {
       newValue: 2
     })
 
-    // @ts-ignore
     delete obj.foo
     await nextTick()
     expect(dummy).toBeUndefined()
index 8963bda2649043fc4c50403bee2c86c976b67d3f..053d87140e900db42daeac6957886ce578836e9e 100644 (file)
@@ -153,7 +153,7 @@ describe('component: emit', () => {
       emits: ['foo'],
       render() {},
       created() {
-        // @ts-ignore
+        // @ts-expect-error
         this.$emit('bar')
       }
     })
@@ -170,7 +170,7 @@ describe('component: emit', () => {
       },
       render() {},
       created() {
-        // @ts-ignore
+        // @ts-expect-error
         this.$emit('bar')
       }
     })
@@ -186,7 +186,7 @@ describe('component: emit', () => {
       emits: [],
       render() {},
       created() {
-        // @ts-ignore
+        // @ts-expect-error
         this.$emit('foo')
       }
     })