You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
error TS2345: Argument of type '((data: { x: number; }[]) => { x: number; }[]) | ((data: { x: number; }[]) => Point[])' is not assignable to parameter of type '(input: { x: number; }[]) => { x: number; }[]'.
Type '(data: { x: number; }[]) => Point[]' is not assignable to type '(input: { x: number; }[]) => { x: number; }[]'.
Type 'Point[]' is not assignable to type '{ x: number; }[]'.
Type 'Point' is not assignable to type '{ x: number; }'.
Types of property 'x' are incompatible.
Type 'number | undefined' is not assignable to type 'number'.
Type 'undefined' is not assignable to type 'number'.
16 modify
~~~~~~
17 ? map(modify)
~~~~~~~~~~~~~~~~~~~
18 : map((point) => point),
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This turns out to be the same issue as in #798. In the call to pipe we infer two candidates for B: { x: number }[] and Point[]. Neither is a supertype of the other, so inference picks the "first" candidate. With tsc this happens to be Point[], but due to differences in type ordering, with tsgo it is { x: number }[]. Unfortunately, the only inference that actually works out is Point[], so an error results with tsgo. It's entirely possible that there is some reordering of declarations that would also cause the error to occur with tsc.
The issue is easy to work around by adding a type assertion to the first argument, as in [{ x: 0 }] as Point[]. Again, ideally our inference algorithm would do better here, but there's no immediately apparent fix. There is some interesting discussion on the topic in this issue: microsoft/TypeScript#40665.
yet another little difference
(types are mostly copied from
remeda
)TS 5.8 is OK with that: playground
If we merge
{ x?: number } & { y?: number }
as{ x?: number; y?: number }
the error disappears (but in my core I merge different types).The text was updated successfully, but these errors were encountered: