当前位置:网站首页>【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.
边栏推荐
猜你喜欢

type="module" you know, but type="importmap" you know

Dry goods!A highly structured and sparse linear transformation called Deformable Butterfly (DeBut)

苏州大学:从PostgreSQL到TDengine

numpy

MySQL数据库高级使用

for in 和 for of的区别

pixel手机升系统

干货!一种被称为Deformable Butterfly(DeBut)的高度结构化且稀疏的线性变换

三大产品力赋能欧萌达OMODA5

Skills required to be a good architect: How to draw a system architecture that everyone will love?What's the secret?Come and open this article to see it!...
随机推荐
机器学习(公式推导与代码实现)--sklearn机器学习库
Mysql OCP 74 questions
Dry goods!A highly structured and sparse linear transformation called Deformable Butterfly (DeBut)
嵌入式软件组件经典架构与存储器分类
Regulation action for one hundred days during the summer, more than 700 traffic safety hidden dangers were thrown out
数字藏品和ICP
怎么在外头使用容器里php命令
深入解析分布式文件系统的一致性的实现
MapReduce中ETL数据清洗案例
APENFT FOUNDATION官宣2022艺术梦想基金主题征集
试题G:单词分析 ← 第十一届蓝桥杯大赛第二场省赛赛题
跨链桥协议 Nomad 遭遇黑客攻击,损失超 1.5 亿美元
混动产品谁更吃香,看技术还是看市场?
【二分查找详解外加递归写法】附有全部代码
error C2872: “flann”: 不明确的符号 解决方法
build --repot
白帽黑客与留守儿童破壁对“画”!ISC、中国光华科技基金会、光明网携手启动数字安全元宇宙公益展
STM32+OLED显示屏制作指针式电子钟
SAP 电商云 Spartacus UI 的 External Routes 设计明细
Guys, I have a problem: My source mysql has a table that has been writing to, I use mysql cdc connec