Skip to content

Regression in Type Inference for functions derived from typeclasses in TypeScript 5.5.x #3171

@gcanti

Description

@gcanti

What version of Effect is running?

3.4.7 (and @effect/typeclass@0.24.39)

What steps can reproduce the bug?

import * as OptionInstances from "@effect/typeclass/data/Option";
import * as RecordInstances from "@effect/typeclass/data/Record";

const traverse = RecordInstances.Traversable.traverse(OptionInstances.Applicative);

What is the expected behavior?

In TypeScript version 5.4.x, hovering over traverse displays the following type information:

const traverse: {
    <A, R, O, E, B>(f: (a: A) => Option<B>): <TR, TO, TE>(self: ReadonlyRecord<string, A>) => Option<ReadonlyRecord<string, B>>;
    <TR, TO, TE, A, R, O, E, B>(self: ReadonlyRecord<string, A>, f: (a: A) => Option<B>): Option<ReadonlyRecord<string, B>>;
}

What do you see instead?

After updating to TypeScript 5.5.x, the hover information shows a more complex and less intuitive type definition:

const traverse: {
    <A, R, O, E, B>(f: (a: A) => Kind<OptionTypeLambda, R, O, E, B>): <TR, TO, TE>(self: Kind<ReadonlyRecordTypeLambda<string>, TR, TO, TE, A>) => Kind<OptionTypeLambda, R, O, E, Kind<ReadonlyRecordTypeLambda<...>, TR, TO, TE, B>>;
    <TR, TO, TE, A, R, O, E, B>(self: ReadonlyRecord<...>, f: (a: A) => Kind<OptionTypeLambda, R, O, E, B>): Kind<OptionTypeLambda, R, O, E, Kind<ReadonlyRecordTypeLambda<...>, TR, TO, TE, B>>;
}

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions