diff --git a/docs/ja/reference/function/partial.md b/docs/ja/reference/function/partial.md index cca2c17e4..83d344044 100644 --- a/docs/ja/reference/function/partial.md +++ b/docs/ja/reference/function/partial.md @@ -11,7 +11,7 @@ Symbol型の`partial.placeholder`を使用すると、前もって提供した ## インターフェース ```typescript -function partial any>(func: F, ...partialArgs: any[]): F; +function partial any>(func: F, ...partialArgs: any[]): (...args: any[]) => ReturnType; namespace partial { placeholder: symbol; @@ -25,7 +25,7 @@ namespace partial { ### 戻り値 -(`F`): 前もって引数が提供された関数。 +(`(...args: any[]) => ReturnType`): 前もって引数が提供された関数。 ## 例 diff --git a/docs/ja/reference/function/partialRight.md b/docs/ja/reference/function/partialRight.md index f545c7135..9891cc3b7 100644 --- a/docs/ja/reference/function/partialRight.md +++ b/docs/ja/reference/function/partialRight.md @@ -11,7 +11,7 @@ Symbol型の`partialRight.placeholder`を使用すると、事前に提供した ## インターフェース ```typescript -function partialRight any)>(func: F, ...partialArgs: any[]): F; +function partialRight any)>(func: F, ...partialArgs: any[]): (...args: any[]) => ReturnType; namespace partialRight { placeholder: symbol; @@ -25,7 +25,7 @@ namespace partialRight { ### 戻り値 -(`F`): 事前に引数が提供された関数。 +(`(...args: any[]) => ReturnType`): 事前に引数が提供された関数。 ## 例 diff --git a/docs/ko/reference/function/partial.md b/docs/ko/reference/function/partial.md index ff153b08d..614e9ee51 100644 --- a/docs/ko/reference/function/partial.md +++ b/docs/ko/reference/function/partial.md @@ -11,7 +11,7 @@ Symbol 타입의 `partial.placeholder`를 쓰면, 미리 제공한 인자가 사 ## 인터페이스 ```typescript -function partial any>(func: F, ...partialArgs: any[]): F; +function partial any>(func: F, ...partialArgs: any[]): (...args: any[]) => ReturnType; namespace partial { placeholder: symbol; @@ -25,7 +25,7 @@ namespace partial { ### 반환 값 -(`F`): 미리 인자가 제공된 함수. +(`(...args: any[]) => ReturnType`): 미리 인자가 제공된 함수. ## 예시 diff --git a/docs/ko/reference/function/partialRight.md b/docs/ko/reference/function/partialRight.md index 2a756e927..6a463caa2 100644 --- a/docs/ko/reference/function/partialRight.md +++ b/docs/ko/reference/function/partialRight.md @@ -11,7 +11,7 @@ Symbol 타입의 `partialRight.placeholder`를 쓰면, 미리 제공한 인자 ## 인터페이스 ```typescript -function partialRight any)>(func: F, ...partialArgs: any[]): F; +function partialRight any)>(func: F, ...partialArgs: any[]): (...args: any[]) => ReturnType; namespace partialRight { placeholder: symbol; @@ -25,7 +25,7 @@ namespace partialRight { ### 반환 값 -(`F`): 미리 인자가 제공된 함수. +(`(...args: any[]) => ReturnType`): 미리 인자가 제공된 함수. ## 예시 diff --git a/docs/reference/function/partial.md b/docs/reference/function/partial.md index 7d0fbeb8e..f7e212521 100644 --- a/docs/reference/function/partial.md +++ b/docs/reference/function/partial.md @@ -11,7 +11,7 @@ Note: This method doesn't set the `length` property of partially applied functio ## Signature ```typescript -function partial(func: F, ...partialArgs: any[]): F; +function partial(func: F, ...partialArgs: any[]): (...args: any[]) => ReturnType; namespace partial { placeholder: symbol; @@ -25,7 +25,7 @@ namespace partial { ### Returns -(`F`): Returns the new partially applied function. +(`(...args: any[]) => ReturnType`): Returns the new partially applied function. ## Examples diff --git a/docs/reference/function/partialRight.md b/docs/reference/function/partialRight.md index 28320365b..47d8bfcd7 100644 --- a/docs/reference/function/partialRight.md +++ b/docs/reference/function/partialRight.md @@ -11,7 +11,7 @@ Note: This method doesn't set the `length` property of partially applied functio ## Signature ```typescript -function partialRight(func: F, ...partialArgs: any[]): F; +function partialRight(func: F, ...partialArgs: any[]): (...args: any[]) => ReturnType; namespace partialRight { placeholder: symbol; @@ -25,7 +25,7 @@ namespace partialRight { ### Returns -(`F`): Returns the new partially applied function. +(`(...args: any[]) => ReturnType`): Returns the new partially applied function. ## Examples diff --git a/docs/zh_hans/reference/function/partial.md b/docs/zh_hans/reference/function/partial.md index 8a2324ad1..70fcb710d 100644 --- a/docs/zh_hans/reference/function/partial.md +++ b/docs/zh_hans/reference/function/partial.md @@ -11,7 +11,7 @@ ## 签名 ```typescript -function partial(func: F, ...partialArgs: any[]): F; +function partial(func: F, ...partialArgs: any[]): (...args: any[]) => ReturnType; namespace partial { placeholder: symbol; @@ -25,7 +25,7 @@ namespace partial { ### 返回值 -(`F`): 返回新的部分应用函数。 +(`(...args: any[]) => ReturnType`): 返回新的部分应用函数。 ## 示例 diff --git a/docs/zh_hans/reference/function/partialRight.md b/docs/zh_hans/reference/function/partialRight.md index 6f821b0ce..f2261b43f 100644 --- a/docs/zh_hans/reference/function/partialRight.md +++ b/docs/zh_hans/reference/function/partialRight.md @@ -11,7 +11,7 @@ ## 签名 ```typescript -function partialRight(func: F, ...partialArgs: any[]): F; +function partialRight(func: F, ...partialArgs: any[]): (...args: any[]) => ReturnType; namespace partialRight { placeholder: symbol; @@ -25,7 +25,7 @@ namespace partialRight { ### 返回值 -(`F`): 返回新的部分应用函数。 +(`(...args: any[]) => ReturnType`): 返回新的部分应用函数。 ## 示例 diff --git a/src/compat/util/iteratee.spec.ts b/src/compat/util/iteratee.spec.ts index 3feb47f1f..61e794de5 100644 --- a/src/compat/util/iteratee.spec.ts +++ b/src/compat/util/iteratee.spec.ts @@ -133,13 +133,9 @@ describe('iteratee', () => { const expected = [1, 2, 3]; const object = { a: 1, iteratee: iteratee(partial(fn, 2)) }; - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-expect-error expect(object.iteratee(3)).toEqual(expected); object.iteratee = iteratee(partialRight(fn, 3)); - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-expect-error expect(object.iteratee(2)).toEqual(expected); }); diff --git a/src/function/partial.spec.ts b/src/function/partial.spec.ts index 49ddd8c27..246a5f5f4 100644 --- a/src/function/partial.spec.ts +++ b/src/function/partial.spec.ts @@ -14,7 +14,7 @@ describe('partial', () => { }); it('partial creates a function that can be invoked with additional arguments', () => { - const fn = function (a?: string, b?: string) { + const fn = function (a: string, b: string) { return [a, b]; }; const par = partial(fn, 'a'); @@ -70,7 +70,7 @@ describe('partial', () => { }); it('partial clones metadata for created functions', () => { - function greet(greeting?: string, name?: string) { + function greet(greeting: string, name: string) { return `${greeting} ${name}`; } diff --git a/src/function/partial.ts b/src/function/partial.ts index fe3ad0c65..22bc1b1bd 100644 --- a/src/function/partial.ts +++ b/src/function/partial.ts @@ -8,7 +8,7 @@ * @template F The type of the function to partially apply. * @param {F} func The function to partially apply arguments to. * @param {any[]} partialArgs The arguments to be partially applied. - * @returns {F} Returns the new partially applied function. + * @returns {(...args: any[]) => ReturnType} Returns the new partially applied function. * * @example * function greet(greeting, name) { @@ -24,7 +24,10 @@ * greetFred('hi'); * // => 'hi fred' */ -export function partial any>(func: F, ...partialArgs: any[]): F { +export function partial any>( + func: F, + ...partialArgs: any[] +): (...args: any[]) => ReturnType { return function (this: any, ...providedArgs: any[]) { const args: any[] = []; diff --git a/src/function/partialRight.spec.ts b/src/function/partialRight.spec.ts index 55170f922..ec0555881 100644 --- a/src/function/partialRight.spec.ts +++ b/src/function/partialRight.spec.ts @@ -14,7 +14,7 @@ describe('partialRight', () => { }); it('partialRight creates a function that can be invoked with additional arguments', () => { - const fn = function (a?: string, b?: string) { + const fn = function (a: string, b: string) { return [a, b]; }; const par = partialRight(fn, 'a'); @@ -71,7 +71,7 @@ describe('partialRight', () => { }); it('partialRight clones metadata for created functions', () => { - function greet(greeting?: string, name?: string) { + function greet(greeting: string, name: string) { return `${greeting} ${name}`; } diff --git a/src/function/partialRight.ts b/src/function/partialRight.ts index f96e06ead..20007283b 100644 --- a/src/function/partialRight.ts +++ b/src/function/partialRight.ts @@ -8,7 +8,7 @@ * @template F The type of the function to partially apply. * @param {F} func The function to partially apply arguments to. * @param {any[]} partialArgs The arguments to be partially applied. - * @returns {F} Returns the new partially applied function. + * @returns {(...args: any[]) => ReturnType} Returns the new partially applied function. * * @example * function greet(greeting, name) { @@ -24,7 +24,10 @@ * sayHelloTo('fred'); * // => 'hello fred' */ -export function partialRight any>(func: F, ...partialArgs: any[]): F { +export function partialRight any>( + func: F, + ...partialArgs: any[] +): (...args: any[]) => ReturnType { return function (this: any, ...providedArgs: any[]) { const placeholderLength = partialArgs.filter(arg => arg === partialRightPlaceholder).length; const rangeLength = Math.max(providedArgs.length - placeholderLength, 0);