Re:Upgrading GitHub from Rails 3.2 to 5.2
by zamalek on Friday September 28, 2018 @04:37PM
(#18096837)
The "implicit opt-out" is noImplicitAny[1]. That code of yours won't compile with this opt-out enabled. Edit: the "dynamic opt-in" is `any` (and is `dynamic` in C#).
[1]: https://www.typescriptlang.org/docs/handbook/compiler-option...
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.
function foo() {
return 1;
}
let x = foo().substring(1, 2);
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.
This is not like C#, where would be required to specify that every type is "dynamic". Here, you can optionally choose to specify that the types are "Any", but it's still gradual typing.
EDIT: you said "implicit opt-out"... which sounds like a synonym for "opt-in". I don't think "implicit opt-out" is a term.