New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect type inference in v0.21.0 #266
Comments
We did not change anything in const n = parse(
transform(string(), (input) => parseInt(input, 10), number([minValue(0)])),
'1'
); |
If you stick with the generics as a workaround, I recommend changing the second generic to the first argument of const n = parse(
transform(string(), (input) => parseInt(input, 10), [minValue<number, 0>(0)]),
"1",
); |
I can use the schema workaround for now, it helps, thanks! |
Unfortunately, I haven't found a solution other than the workaround, and I'm not sure there is one. The problem is that TypeScript no longer resolves the types correctly since the internal change from a function to an object. I'll take another look at the problem in the next few weeks. |
Thanks for the effort. I'm totally fine with the workaround. But IMO if using pipes as the third argument of |
Yes, that is why I did not close this issue. I think it is not a TypeScript bug, just a different behavior than expected on our end. I will investigate this again in the coming weeks. If there is no solution, we could simply not allow a pipe as a third argument. |
Again, thanks for your effort and appreciate your time! @fabian-hiller |
This should no longer be a problem with the latest version. |
Hello,
I was able to use this 馃憞 code to parse a string into a number in v0.20.1 and get the correct type for
n
(number
):But when I updated to v0.21.0, the inferred type of
n
of the same code becamestring | number | bigint | boolean | Date
.I have to change it to this 馃憞 to fix the type.
Did I miss something?
Thanks
The text was updated successfully, but these errors were encountered: