@noelrap I have no experience with types in Ruby, but in TypeScript, I do it the opposite way: Type the arguments, but almost always let the tooling infer the return type. I feel this ensures I always have good autocompletion and the return types are better/stricter than if I typed them myself.

I feel like relying on coercion would be more difficult once you have more custom types that don‘t easily convert into each other.

(But JavaScript also does not have the nice coercion capabilities.)

1
Share
Share on Mastodon
Share on Twitter
Share on Facebook
Share on Linkedin
Replies