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
ReadonlyNonEmpty arrays are problematic when used in mapped types.
In the provided example the error message is:
Type 'T[K]' does not satisfy the constraint 'string'.
Type 'T[keyof T]' is not assignable to type 'string'.
Type 'T[string] | T[number] | T[symbol]' is not assignable to type 'string'.
Type 'T[string]' is not assignable to type 'string'.
Expected behavior
There should be no error in the example I provided.
🐛 Bug report
Current Behavior
ReadonlyNonEmpty arrays are problematic when used in mapped types.
In the provided example the error message is:
Expected behavior
There should be no error in the example I provided.
Reproducible example
the problem is at line 5 with a generic argument
T[K]
.Suggested solution(s)
It's probably caused by the type intersection with
{ readonly 0: T }
in here:I assume that TypeScript finds a possibility of
T[string]
because of the object-like fragment in the intersection.Probably the solution is identical to #1830 I've tested it and it works as expected in my scenario:
Your environment
Which versions of fp-ts are affected by this issue? Did this work in previous versions of fp-ts?
Certainly my version, I have no idea whether or not it worked in previous versions but the problem is too straightforward to assume that it did.
The text was updated successfully, but these errors were encountered: