gcanti / fp-ts

Functional programming in TypeScript
https://gcanti.github.io/fp-ts/
MIT License
10.63k stars 503 forks source link

sequenceT / TaskEither type problem with 2.16.6 #1944

Closed markanye closed 5 days ago

markanye commented 5 days ago

🐛 Bug report

With fp-ts 2.16.5 and typescript 5.5.2, this is valid code:


import * as TE from "fp-ts/lib/TaskEither";
import { sequenceT } from "fp-ts/lib/Apply";

const doAfter = (delay: number): TE.TaskEither<Error, string> => TE.tryCatch(
  () => new Promise((resolve) => setTimeout(() => resolve('done'), delay)),
  (reason) => new Error(`failed: ${reason}`)
);

export const doAll = sequenceT(TE.ApplicativePar)(doAfter(1000), doAfter(2000));

But after upgrading to fp-ts 2.16.6, the last line throws the following typescript error:

Argument of type '[TaskEither<Error, string>, TaskEither<Error, string>]' is not assignable to parameter of type 'HKT<"TaskEither", any>[] & { readonly 0: HKT<"TaskEither", any>; }'. Type '[TaskEither<Error, string>, TaskEither<Error, string>]' is not assignable to type 'HKT<"TaskEither", any>[]'. Type 'TaskEither<Error, string>' is not assignable to type 'HKT<"TaskEither", any>'.ts(2345)

Software Version(s)
fp-ts 2.16.6
TypeScript 5.5.2
gcanti commented 5 days ago

@markanye I don't get any errors

markanye commented 5 days ago

On closer inspection, you're right. It compiles fine for me too, but is displayed as an error in VSCode.

vscode-error

Oddly, VSCode is configured with the same typescript install that I'm using for compilation. The issue goes away if I downgrade to 2.16.5.

gcanti commented 5 days ago

Weird, I'm a VSCode user too, and everything is fine for me