@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
Noel Rappin

@danieldiekmeier I think it kind of depends on what kind of problem you are trying to solve and what kind of problem you are trying to avoid...

I haven't actually tried this, so I don't really know how it would work. It wouldn't surprise me if the Ruby tooling and TypeScript tooling had slightly different effects.

1
3mo
Replies