Skip to content

Call signature of take can prevent type inferrence when using curried signature #69

Description

@TClark1011

The current typing of the take function is this:

export function take(n: number): {
  (xs: string): string;
  <T>(xs: readonly T[]): T[];
};
export function take(n: number, xs: string): string;
export function take<T>(n: number, xs: readonly T[]): T[];

Right now, when you call the curried signature inside a pipe, the type of the array is not correctly inferred:

image You can see the type inference is working correctly without the `R.take` call: image

The solution is to change the curried signature for taking from an array to this:

export function take<T>(n:number): (xs: readonly T[]) => T[]

This also applies to takeLast.

I would be happy to open a PR for this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions