I thought most languages were moving away from header files. I know typescript has similar files but that is out of necessity as it is added to a language that has no idea typescript exists
I thought most languages were moving away from header files. I know typescript has similar files but that is out of necessity as it is added to a language that has no idea typescript exists
I think it might be worth the headache with libraries - I think type errors are more useful when you cross the boundary into someone else's code. They're still useful within apps, of course, but personally I don't think I hit them often enough to make the headaches of a separate file worthwhile.
My hope is that this is primarily motivated by wanting to maintain backwards compatibility for source, and maybe as more of the ruby ecosystem moves to 3.x future versions will add an alternative way of doing type annotations inline.
Something I've wondered about rbs files since I first heard about them is, can we combine rbs descriptions with our unit tests?
That would seem to make sense to me and help support TDD/BDD.
Otherwise I'd probably stick to Sorbet in-line type definitions for ruby.
For example, the ORM ActiveRecord reads the database schema at runtime and generates the getters and setters for each column for the appropriate class. The class itself doesn't have any code listing these columns. Where would the inline annotation go?
I'm pretty confused as to why you would want to have annotations baked into your source code anyway, if you are reading the database schema at runtime.