]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(types): remove explicit return type annotation requirement for `this` inference...
authorAmour1688 <lcz_1996@foxmail.com>
Mon, 2 Aug 2021 13:18:35 +0000 (21:18 +0800)
committerGitHub <noreply@github.com>
Mon, 2 Aug 2021 13:18:35 +0000 (09:18 -0400)
packages/reactivity/src/computed.ts
test-dts/defineComponent.test-d.tsx

index 4c984d3d65aa1d8049c437d19ab23f040ec2a34d..3b3734388a1be416ceed4cb6e810ea3d96e7d9e3 100644 (file)
@@ -12,7 +12,7 @@ export interface WritableComputedRef<T> extends Ref<T> {
   readonly effect: ReactiveEffect<T>
 }
 
-export type ComputedGetter<T> = (ctx?: any) => T
+export type ComputedGetter<T> = (...args: any[]) => T
 export type ComputedSetter<T> = (v: T) => void
 
 export interface WritableComputedOptions<T> {
index dba11f20b9b4718dce6712b091f8b533302f563d..b28bbed6b4a951de24a34231bdb89522c12cc8c5 100644 (file)
@@ -396,12 +396,12 @@ describe('type inference w/ options API', () => {
       }
     },
     computed: {
-      d(): number {
+      d() {
         expectType<number>(this.b)
         return this.b + 1
       },
       e: {
-        get(): number {
+        get() {
           expectType<number>(this.b)
           expectType<number>(this.d)
 
@@ -514,10 +514,10 @@ describe('with mixins', () => {
       expectType<string>(props.aP1)
     },
     computed: {
-      dC1(): number {
+      dC1() {
         return this.d + this.a
       },
-      dC2(): string {
+      dC2() {
         return this.aP1 + 'dC2'
       }
     }
@@ -926,7 +926,7 @@ describe('emits', () => {
     },
     mounted() {
       // #3599
-      this.$nextTick(function() {
+      this.$nextTick(function () {
         // this should be bound to this instance
 
         this.$emit('click', 1)