当前位置:网站首页>【TypeScript】Why choose TypeScript?
【TypeScript】Why choose TypeScript?
2022-08-03 10:53:00 【Ji Shuaizhen's web log】
Self-introduction: Hello everyone, my name is Ji Shuaizhen's network log (the account name is the same on other platforms), Internet front-end development engineer, worked for 5 years, went to Shanghai and Beijing, experienced startups, joined the Ali local life team, and nowZhengzhou Beiyou Education is engaged in programming training.
I. Introduction
TypeScript is essentially the same as JavaScript. You can understand TypeScipt as a JavaScript with type annotations, such as const num = 1, which conforms to both TypeScript and JavaScript syntax.In addition, TypeScript is an intermediate language, and ultimately it needs to be translated into pure JavaScript, and then handed over to various terminals for interpretation and execution.However, TypeScript will not destroy the existing knowledge system of JavaScript, because it does not create a new syntax that is completely different from JavaScript, it is still a "familiar recipe" and "familiar flavor".
Second, TypeScript is more reliable
After the introduction of TypeScript into business applications, when we received an alarm from Sentry (an open source front-end error monitoring system), about "'undefined' is not a function" and "Cannot read property 'xx' of null|undefined"Low-level error stats like this are largely absent.And this is thanks to the static type detection of TypeScript, so that at least 10% of JavaScript errors (mainly some low-level errors) can be found and solved during the development phase.Before any operator, TypeScript can detect whether the received type (when the code is running, the operator receives the actual data; when static detection, the operator receives the type) is supported by the current operator.
When TypeScript type detection capabilities cover the entire file, the entire project code, any changes that break the contract can be automatically detected (even across multiple files, many passes), and type errors are raised.Therefore, you can safely modify and refactor business logic without worrying too much about making low-level mistakes due to ill-consideration.
When taking over a complex and large-scale application, TypeScript can make the application easy to maintain, iterative, stable and reliable, and it will also make you feel more secure.
Three, interface-oriented programming
The essence of writing TypeScript type annotations is interface design.An example of a React component designed to display user information using TypeScript, from which we can understand the structure and type of data received by the component at a glance, and clearly know how to write safe and stable JSX code inside the component.
interface IUserInfo {/** user id */id: number;/** username */name: string;/** avatar */avatar?: string;}function UserInfo(props: IUserInfo) {...}
TypeScript has the potential to change the way you think, making it a good habit over time.For example, before writing specific logic, we need to design the data structure, write type annotations, and implement business logic according to this interface convention.This can obviously reduce unnecessary code refactoring, thereby greatly improving coding efficiency.At the same time, you will better understand the importance of interface conventions, and you will also constrain yourself/others to design interfaces, write annotations, and abide by conventions.
Fourth, TypeScript is becoming mainstream
Compared to the rival Facebook's Flow, TypeScript has the advantage of type programming, and it is also endorsed by two international companies, Microsoft and Google.In addition, more and more mainstream frameworks (such as React, Vue 3, Angular, Deno, Nest.js, etc.) either choose TypeScript to write source code, or provide perfect support for TypeScript.With the popularity of TypeScript, TypeScript has become a mainstream technical direction in China (domestic lags behind foreign countries). Major domestic Internet companies and small and medium-sized teams have begun to try to use TypeScript to develop projects, and more and more people are learning and using it.it.
V. Summary
Proficient in TypeScript, you can easily win offers from big manufacturers.
边栏推荐
- 如何将Oracle/MySQL中的数据迁移到GBase 8c中?
- 袋鼠云思枢:数驹 DTengine,助力企业构建高效的流批一体数据湖计算平台
- 混动产品谁更吃香,看技术还是看市场?
- Mysql OCP 74 questions
- 【网络原理的概念】
- Why is the new earth blurred, in-depth analysis of white balls, viewing pictures, and downloading problems
- 月薪没到35K的程序员必须要背的面试八股,我先啃为敬!
- LeetCode_二分搜索_简单_367.有效的完全平方数
- 进入 SQL Client 创建 table 后,在另外一个节点进入 SQL Client 查询不到
- complete knapsack problem
猜你喜欢
【多线程的相关内容】
请问应该用什么关键字将内容主题设置为 dark 呢
synchronized
成对连接点云分割
成为优秀架构师必备技能:怎样才能画出让所有人赞不绝口的系统架构图?秘诀是什么?快来打开这篇文章看看吧!...
如何通过DBeaver 连接 TDengine?
后台图库上传功能
The way of programmer architecture practice: how to design a sustainable evolution system architecture?
[Star Project] Little Hat Plane Battle (9)
Leecode-SQL 1527. 模糊查询匹配(模糊查询用法)
随机推荐
再谈“雷克萨斯”安全装置失效!安全手册疑点重重,网友:细思极恐
Regulation action for one hundred days during the summer, more than 700 traffic safety hidden dangers were thrown out
Basic using MySQL database
redis基础知识总结——数据类型(字符串,列表,集合,哈希,集合)
深度学习100例——卷积神经网络(CNN)实现服装图像分类
如何通过DBeaver 连接 TDengine?
oracle计算同、环比
【冒泡排序以及奇数偶数排列】
Leecode-SQL 1667. 修复表中的名字
Depth study of 100 cases - convolution neural network (CNN) to realize the clothing image classification
Activiti产生的背景和作用
[Star Project] Little Hat Plane Battle (9)
MATLAB程序设计与应用 2.7 结构数据与单元数据
Matplotlib
在 Chrome 开发者工具里通过 network 选项模拟网站的离线访问模式
关于OPENSSL的问题
机器学习(公式推导与代码实现)--sklearn机器学习库
完全背包问题的思路解析
numpy
for in 和 for of的区别