Re:Upgrading GitHub from Rails 3.2 to 5.2
by recursive on Friday September 28, 2018 @04:17PM
(#18096694)
If it was really not a statically typed language, I'd expect this code to at least run. But it detects a type failure at compilation time despite the lack of any declarations.
[ Parent
| on HN ]
Re:Upgrading GitHub from Rails 3.2 to 5.2
by coder543 on Friday September 28, 2018 @04:20PM
(#18096713)
> I'd expect this code to at least run
It still compiles the code to JavaScript even with the error, and you can still run it, which makes this more of a warning than anything else.
That warning based on type inference seems like a positive feature... because there's no situation in which that code is right. You can add `: any` to the function declaration and it will stop complaining, but I wouldn't contend that the language is not dynamic because it encourages you not to make a mistake.
Re:Upgrading GitHub from Rails 3.2 to 5.2
by int_19h on Friday September 28, 2018 @06:19PM
(#18097514)
The distinction between "warning" and "error" is highly arbitrary anyway. In C++, you also get a warning rather than an error if you, say, return a reference to a local, or read from an uninitialized local. You still get a binary, and it still runs. But these are 100% bugs, which is why most projects enable treat-warnings-as-errors for a lot of that stuff in C++. I'd imagine it's common with TypeScript, as well.