๐ Svelte is moving away from TypeScript **and how this will change the world of typing
**The news has already been discussed 100k times, but I'll jump on the hype train and tell you something interesting, based on 2 facts:
- I never want to write applications without typing.
- I don't think that when creating libraries, typing is necessarily required.
And TypeScript gives 10 times more than most other typed languages:
There's a very strange case โ when you're writing some abstract code that will be used in different contexts of other developers' codebases, typing can start to interfere a lot.
Yes, you should 1000% type your inputs (function arguments) and outputs (function results), but library authors often reduce the contents of these functions to any, because in such code, you need performance and non-type-safe operations that take into account the context.
Library code should adapt to the developer's context, and therefore be "dynamic", not "static".
BUT this doesn't mean that typing is getting in the way. Absolutely not. Because in the end, you NEED to describe the correct typed inputs and outputs.
And that's where TypeScript comes in, allowing you to write library code in JS (or even a single file) and then cover it with .d.ts, which is essentially a header file .h from the world of C.
That is, we write non-type-safe code as we need, and then cover it with types so that it's convenient for other developers.
This approach is disliked by most TS developers, BUT not because of the "incorrectness" of the approach, but because most projects written in this way are crap from a typing perspective (types are incomplete, erroneous, super complex, and impossible to customize)
And again "BUT": libraries with crappy .d.ts were written without considering TS in the first place, it was added later as an afterthought.
If a library creator writes .js with consideration for how it will work in .ts, you won't even notice the difference.
- you can always make a hack where only 1-n files out of the entire library are in JS, and the rest are in TS, if needed.
In short, our task is to use typing for our own good and for the good of other developers, and sometimes this means taking not the "standard path", but the "right path".
Wishing you all powerful roads ๐ฃ๏ธ