In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly shows you "Why not use TypeScript", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "Why not use TypeScript" this article.
There are risks.
Wow. What is the risk if TypeScript adds type definitions and checks them at compile time? does the IDE integration also warn you about any type mismatches? That's why. TypeScript checks for types only at compile time and only for available types. No network calls, system libraries, platform-specific API and untyped third-party libraries can communicate with TypeScript. Errors and errors appear when you are used to checking types and do not have a complete understanding of the code and platform.
With JS, you don't need to make any assumptions about the type, and you can check the specific value of the variable to make sure it meets your expectations. Or, if you don't care about the type in this case, you don't have to. In TS, you rely on the compiler to do this for you, but it can only do a lot of checking. You can combine these two ways, what's the point? If you take the time to write definitions and then spend time writing code to ensure that they are maintained at run time, why use them in the first place?
It's so messy.
Another paradox: the language that is supposed to bring clarity and readability to the code base blurs it. To illustrate what I mean, take a look at some examples I found in the popular open source libraries:
/ / TODO: do this more elegantly; ((currentReducer as unknown) as Reducer
< NewState, NewActions >) = nextReducer
This is from the Redux library, and all four lines of code assign nextReducer to currentReducer.
/ / HACK: Since TypeScript inherits static properties too, we have to / / fight against TypeScript here so Subject can have a different static create signature / * Creates a new cold Observable by calling the Observable constructor * @ static true * @ owner Observable * @ method create * @ param {Function} subscribe? The subscriber function to be passed to the Observable constructor * @ return {Observable} a new cold observable * @ nocollapse * @ deprecated use new Observable () instead * / static create: Function = (subscribe?: (subscriber: Subscriber) = > TeardownLogic) = > {return new Observable (subscribe);}
The next example comes from the RxJS library. I don't know about you, but if I have to use a tool that can help me, then I don't think it's a good tool.
It doesn't solve the problem.
It is said that TypeScript can solve the JavaScript problem. But this is not the case. Dynamic typing has never been a problem in JavaScript, but many other pitfalls, such as NaN = NaN is false, semicolons are optional or non-optional, newline characters change the object definition to scope, and using grammatical sugar instead of OOP is a problem. Instead of solving these problems, TypeScript has introduced another standard that further divides the JS community.
Even assuming that the lack of typing in JS is a problem, TS cannot solve it. Did you know that Java,C,C# and other compiled languages. They can safely guarantee strong typing at compile time and run time. Interpreting language cannot do this.
It's not a superset, it's a subset.
TypeScript is something that can be compiled into JavaScript, and by definition it cannot be a superset. It limits what you can do with JavaScript, masks its strengths, and provides fake security. If you really want to be a good developer, don't lie to comfort yourself, but try to understand the true capabilities and flexibility of JavaScript.
It's open source, that's all.
Many reasons for using TypeScript indicate that it is open source. Yes, the TS compiler is distributed under the MIT license. But it is still controlled by Microsoft (a monopoly company), and its open source progress is nothing more than a marketing move. Don't confuse open source with democracy: Microsoft is still free to use TS to do whatever you want, and you can watch it right here. JS, on the other hand, is governed by an international committee and will not change anything without community approval.
But big companies use it.
I can't believe some people think this is a reason. Large companies also use old code bases to commit tax fraud and discriminate against women. Why is the sudden use of TypeScript a good example?
But it has more functions.
No more. Indeed, when TS was first introduced in 2012, it had features such as classes, but it was still not available in JS. But JS has come a long way since then, and now TS is trying to keep up. If anything is missing in JS, you can use the babel plug-in to do it.
The above is all the content of the article "Why not use TypeScript". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.