From da3fb4fb1d24ad63a592871953319227d69538cf Mon Sep 17 00:00:00 2001 From: Bohdan Klochko Date: Thu, 20 Apr 2023 11:50:11 +0300 Subject: [PATCH 1/3] Fixes typescript definition for "when" and "unless" methods --- index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.d.ts b/index.d.ts index 95618a0..c44ddfd 100644 --- a/index.d.ts +++ b/index.d.ts @@ -452,7 +452,7 @@ declare module 'collect.js' { /** * The unless method will execute the given callback when the first argument given to the method evaluates to false. */ - unless(value: boolean, fn: (this: any) => any, defaultFn: (this: any) => any): void; + unless(value: boolean, fn: (this: any) => any, defaultFn?: (this: any) => any): Collection|any; /** * The unwrap method will unwrap the given collection. @@ -467,7 +467,7 @@ declare module 'collect.js' { /** * The when method will execute the given callback when the first argument given to the method evaluates to true. */ - when(condition: boolean, fn: (this: any) => any, defaultFn: (this: any) => any): void; + when(condition: boolean, fn: (this: any) => any, defaultFn?: (this: any) => any): Collection|any; /** * The where method filters the collection by a given key / value pair. From 563075b3e387ec81af4092cd94f043241d3907c4 Mon Sep 17 00:00:00 2001 From: Bohdan Klochko Date: Mon, 7 Oct 2024 16:43:38 +0300 Subject: [PATCH 2/3] fix ts for unless and when methods --- index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.d.ts b/index.d.ts index c44ddfd..8bf99d1 100644 --- a/index.d.ts +++ b/index.d.ts @@ -452,7 +452,7 @@ declare module 'collect.js' { /** * The unless method will execute the given callback when the first argument given to the method evaluates to false. */ - unless(value: boolean, fn: (this: any) => any, defaultFn?: (this: any) => any): Collection|any; + unless(condition: boolean, fn: (collection: Collection) => Collection, defaultFn?: (collection: Collection) => Collection): Collection; /** * The unwrap method will unwrap the given collection. @@ -467,7 +467,7 @@ declare module 'collect.js' { /** * The when method will execute the given callback when the first argument given to the method evaluates to true. */ - when(condition: boolean, fn: (this: any) => any, defaultFn?: (this: any) => any): Collection|any; + when(condition: boolean, fn: (collection: Collection) => Collection, defaultFn?: (collection: Collection) => Collection): Collection; /** * The where method filters the collection by a given key / value pair. From a2e873d474d201ef54a1436cdf743f135c8551c8 Mon Sep 17 00:00:00 2001 From: Bohdan Klochko Date: Mon, 7 Oct 2024 18:14:43 +0300 Subject: [PATCH 3/3] fix ts for prepend method --- index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index 8bf99d1..0df49b8 100644 --- a/index.d.ts +++ b/index.d.ts @@ -295,7 +295,7 @@ declare module 'collect.js' { /** * The prepend method adds an item to the beginning of the collection. */ - prepend(value: V, key?: K): this; + prepend(value: V, key?: K): Collection; /** * The pull method removes and returns an item from the collection by its key.