It's too bad Flow has lost the typed-JS battle, I find the syntax to be a lot easier to use.
It's too bad Flow has lost the typed-JS battle, I find the syntax to be a lot easier to use.
[0] https://www.youtube.com/playlist?list=PLw5h0DiJ-9PBIgIyd2ZA1...
Unfortunately, having all that power available is necessary because it has to be able to reasonably describe a highly-dynamic language. The more dynamic your JS is to begin with, the crazier your types will have to be to make sense of it. But most of that craziness can be avoided if you write straightforward logic with straightforward data structures to begin with.
I've had to break out some wild types to describe JS modules I've needed. If I need such things inside a TS application I control, I often see that as a failure to write clean/concise code in the domain language of the application itself rather than some "ideal" abstraction that may not matter (and I expect will eventually crumble into unreadable tech debt).
Or crumble when tsc tries to follow them ;)
I’ve sometimes found, perhaps for the better, that when I get too creative with types the typescript compiler will at some point just not be able to follow what I’m trying to tell it any more. Even though my types are correct, theoretically, it will just sort of tip over. That usually serves as a good sign that I shouldn’t be trying to do what I’m doing at all.
Well, good news, you can use Typescript's compiler as a Js static code analyzer without writing a single line of Typescript!
It is OK if you prefer no solution to some complex typing needs that are solved with complex syntax in Typescript.
Most of Typescript is optional.
It's not trivial to think of simpler alternatives to much of the problems Typescript is tackling.
(And if you have any simplifying syntax suggestions that don't break typing it will be interesting to read)
Yeah, is it. But "complexity" is fine:
Complex is better than complicated.
- [Zend of python](https://www.python.org/dev/peps/pep-0020/)
What is a big trouble is when the complexity is NOT intentionally designed (ie: in languages like oCalm, Rust, Coq...) but instead the type system is a lie that bring "complications": //A bad language, like JS, with both complexity AND complications:
[] - {}; // NaN
Humans can deal with complexity if is part of a intentional design (example: APL), but what we dread is when is accidental... [] - {}
is a fatal typescript error[0]. A well configured linter can also catch out similar nonsense, but
[] - 2
does get past the compiler.The TS Compiler can atleast stop you from doing nonsense like applying operators to types where they don't make sense. Of course, it'd be better if JS just threw an error or something, but atleast TS can stop you.
[0]: The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.ts(2363)
Or did you mean to say that oCaml, Rust, and Coq have intentional design complexity?
yes, more like this (in special Rust, that deal with many challenges like system programming, safety, etc).
[1] https://www.reddit.com/r/JSdev/comments/nl4ccq/is_flow_movin...
Most of this is just the way the language evolved, along JavaScript. I wish they'd abandon the "JavaScript superset idea" and cleaned up the language.
Make the common case simpler and more straightforward, drop everything exotic, it's not practical nor strictly necessary.