gigobyte / purify

Functional programming library for TypeScript - https://gigobyte.github.io/purify/
ISC License
1.52k stars 59 forks source link

Typescript 5.5 types behave poorly #711

Closed stijnveenman closed 2 months ago

stijnveenman commented 3 months ago

Since typescript 5.5, type inference has been improved. This update affected purify-ts type inference in annoying ways. Previously, the following examples used to work

import {Maybe} from 'purify-ts';

const foo = (bar: Maybe<number>) => {
    return bar;
}

console.log(foo(Maybe.zero()));
                ^^^^^^^^^^^^^
Argument of type 'Nothing' is not assignable to parameter of type 'Maybe<number>'.
  Types of property 'isJust' are incompatible.
    Type '() => boolean' is not assignable to type '() => this is AlwaysJust'.
      Signature '(): boolean' must be a type predicate.(2345)
import {Nothing, Just} from 'purify-ts';

export const foo = (a: number) => {
             ^^^
Exported variable 'foo' has or is using name 'AlwaysJust' from external module "file:///node_modules/purify-ts/Maybe" but cannot be named.(4023)
Property '__value' of exported class expression may not be private or protected.(4094)

    return a ? Nothing : Just(5)
}
valpinkman commented 3 months ago

It seems the repo has been updated to use Typescript 5.5.2 about two weeks ago. Any chance to see a new release soon ?

gigobyte commented 2 months ago

The packages are automatically updated by renovate so it does not imply any compatibility unless there is a release with the updated packages. I'll get to investigating the bug this weekend.

valpinkman commented 2 months ago

@gigobyte thank you very much 🙏

gigobyte commented 2 months ago

Test pass for 2.1.0 on my machine, please try it out and close the issue if it's not reproducible anymore.

valpinkman commented 2 months ago

Thanks will try and report

valpinkman commented 2 months ago

Works on our side 👍

stijnveenman commented 2 months ago

We have now been able to update as well, thanks for the quick fix 👍