-
Notifications
You must be signed in to change notification settings - Fork 405
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Typing inline generic operators seems much more annoying with 3.8 (coming from 3.6) #2161
Comments
Hi @dmrickey
This change placed a stricter constraint on how the operators are implemented, but better safety and ergonomics for the users of those operators. It is a very worth while tradeoff, because, typically, operators are only implemented in a few places, and used in many other places. Just a comment on your types, it might be a bit easier if you use the PS. Typescript now actually added a built in |
As an alternative (but a downgrade of experience in my opinion), you could enable your previous experience by wrapping each of the core operator functions with your own functions with the same name, and deliberately don't use the This would degrade your type safety and intellisense enough to the point where the code is as permissive as it was before. Who needs those pesky types anyway! 😉 |
Even with typing the input parameter I still have to cast the const insert = <T extends SessionInformation | SessionTranslation>(item: NoInfer<T>) =>
iif(isTrailer, insertItem<T>(item), append<T>([item] as NoInfer<T[]>)); This is why so many people are moving away from typescript. I'm not trying to be argumentative. I understand overall the tooling is better, but these short one-off examples are beyond ugly now and far less useful |
Let me know if I'm overcomplicating something. This is what we used to have in 3.6
for 3.8 this is what I've got to do now which seems needlessly verbose
Is there something I'm missing here or is it this complex now?
A couple more examples
The text was updated successfully, but these errors were encountered: