gcanti / fp-ts

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

Problem with `array#sequence` type when upgrading fp-ts to 2.8.2 #1309

Open hguerragit opened 4 years ago

hguerragit commented 4 years ago

I got a monorepo where we use fp-ts on almost every package. When upgrading to version 2.8.2 (from version 2.6.2), I got a problem in two of my packages involving array#sequence.

Instead of getting this:

pipe(
    tuples.map(saveThread),
    x => x, // TaskEither<CustomError, RequisitionFileThread>[]
    array.sequence(taskEither),
    x => x, // TaskEither<CustomError, RequisitionFileThread[]>
    map(threads =>
      threads.map((thread, i) => {
        const tuple = tuples[i];
        const [_, file] = tuple;

        return [thread, file] as const;
      })
    )
  )

I'm getting this:

pipe(
    tuples.map(saveThread),
    x => x, // TaskEither<CustomError, RequisitionFileThread>[]
    array.sequence(taskEither),
    x => x, // TaskEither<unknown, any>
    map(threads =>
      threads.map((thread, i) => {
        const tuple = tuples[i];
        const [_, file] = tuple;

        return [thread, file] as const;
      })
    )
  )

The code worked properly in version 2.6.2.

Erros like that popped with other types as well, like Either.

Strangest thing, I use array#sequence in other places (but not in the packages I got those errors) and it seems to work as expected. At first, I thought it was something with typescript or the tsconfig files, but I updated the first and the error was not solved. Looking into my tsconfig files, I found nothing that could cause such.

Anyone has experienced something similar, or know a path to solve this?

samhh commented 3 years ago

I suspect for this to gain traction you'll want to provide a small repro.