Answer the question
In order to leave comments, you need to log in
What is the advantage of Typescript?
What justifies the complication of the process of writing code (waiting for compilation, TSLint in VSCode is terribly tight. I recently saw a guide about accelerating lint from 13sec+ to 5sec. In 5 seconds, catch an error in the console faster. Not to mention that it works every other time)?
Types? There is JSDOC. Any conditional chaining and classes? JS has been doing this for a long time. I tried to write a small server for the MEVN stack on it - the number of type description lines turned out to be slightly less than the number of lines of the main code. Plus, hemorrhoids with types did not go away - because. many nodejs libraries do not have types, you have to write it manually - and this is still that hemorrhagic.
Browser support for compiled code? Yes, almost all JS has 95% + support, the same Babel already forgot when he used it.
At the same time, I see many vacancies where experience in TS is still required.
Answer the question
In order to leave comments, you need to log in
No matter how strange it may sound, one of the main advantages of TypeScript is that it speeds up development several times. Yes, when there is nothing yet, development will slow down slightly, since in addition to logic, types must also be described. But this is only at the beginning. And this is not only the ability to write most of the code using autocompletion. Maintenance of existing code takes ten times more time than its initial writing. Is it worth investing a few extra hours at the start to save months later? As for me it's worth it.
Another huge plus is the ability to design on types. Knowing ZenI stopped using UML in TypeScript, as types give me the same visibility, but they also reduce time, since types are already code. Well, there is only one source of truth. Business requirements expressed in types do not allow deviating from them when writing logic, excluding the possibility of incorrect interpretation of the task. By moving the task to types, I can discuss it with colleagues and correct inaccuracies even before writing code, which again saves a lot of time.
Well, I will answer some of your doubts:
TSLint in VSCode is straight terribly tightTSLint is officially deprecated, you should use a plugin for eslint instead , you can also try my config .
Types? There is a JSDOCJSDoc in terms of types does not know even 10% of what TypeScript can. In addition, no one in their right mind writes JSDoc for private logic, which means there will be no type checking there. JSDoc does not guarantee the correctness of the refactoring, but thanks to TypeScript, again, I will definitely not forget to update JSDoc.
many nodejs libraries don't have typesmaybe 5 years ago it was like that, but now meeting a library without types is rather an exception. If the library is popular, but does not provide types, most likely someone else has already written them, just install the module of the same name from the types scope npm and everything will work by itself.
Browser support for compiled code? Yes, almost all JS has 95% + support, the same Babel already forgot when he used it.In general, this is not the main task of the TypeScript compiler, but an optional feature. And babel + preset-env handle it much better. And no one bothers to use them together. And I also think it's a matter of time when someone writes a code optimizer using type information from TS.
Approximately every second one has instances that you look at - and scratch your turnips - but what is the type of this variable called in @types/?
import {someObject} from 'some-library';
type TypeFromValue = typeof someObject;
const valueCopy: TypeFromValue = {
...someObject,
type: 'overrides',
with: 'type check',
};
and by the way, here's an example of what JSDoc types can't do.//@ts-checkand almost everywhere there will be a useless any.
Types? There is JSDOC.
Ts for people for whom js is not the first, for those who started with it, there are no problems that ts solves, just a different way of thinking and, accordingly, working with code. But there are plenty of such people and ts is accordingly popular, and being able to work with him is a mandatory skill.
There is a type of especially gifted people who "can shoot themselves in the foot."
It's so terrible that it's better not to write in a pure language and everyone suffers additionally.
To have fewer problems, you need to suffer more.
That is, it’s impossible to just write high-quality js, especially if you are crooked.
And some people don't realize that the js css html php sqlite suite is a ready-made simple beautiful framework, and to make the job even easier, they invent an additional 10 times more tools.
The world has gone crazy for a long time - it's obvious.
Web programmers forgot the sacred KISS principle
of dynamic typing Alan Kay said:
Late binding makes it easier to incorporate ideas that come later in the development process into a project (compared to earlier-bound systems like C, C++, Java, etc.)
If you use early-bound languages, as most do, then you lock yourself into the framework of what you have already written. It's not easy to reformulate.
I'm not against types, but I don't know of any type system that doesn't cause pain. So I still like dynamic typing.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question