当前位置:网站首页>【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.
边栏推荐
- MapReduce中ETL数据清洗案例
- How to use outside the PHP command in the container
- 程序员架构修炼之道:软件架构基本概念和思维
- build --repot
- Polymorphism in detail (simple implementation to buy tickets system simulation, covering/weight definition, principle of polymorphism, virtual table)
- LeetCode_二分搜索_简单_367.有效的完全平方数
- 鸿蒙第三次
- 聊天app开发——防炸麦以及节省成本的内容鉴定方法
- GBase 8c分布式数据库,数据如何分布最优?
- 请问应该用什么关键字将内容主题设置为 dark 呢
猜你喜欢
随机推荐
MapReduce中ETL数据清洗案例
消费者认可度较高 地理标志农产品为啥“香”
Leecode-SQL 1527. 模糊查询匹配(模糊查询用法)
训练双塔检索模型,可以不用query-doc样本了?明星机构联合发文
出色的移动端用户验证
谷歌实用插件分享
Mysql OCP 75 questions
成为优秀架构师必备技能:怎样才能画出让所有人赞不绝口的系统架构图?秘诀是什么?快来打开这篇文章看看吧!...
Advanced use of MySQL database
[Star Project] Little Hat Plane Battle (9)
Web Server 设置缓存响应字段的一些推荐方案
4 g acquisition ModbusTCP turn JSON MQTT cloud platform
聊天app开发——防炸麦以及节省成本的内容鉴定方法
Spinner文字显示不全解决办法
3D激光SLAM:LeGO-LOAM---两步优化的帧间里程计及代码分析
pixel手机升系统
试题G:单词分析 ← 第十一届蓝桥杯大赛第二场省赛赛题
What is the relationship between The Matrix and 6G?
BPMN和DMN基本概念和使用案例
Guys, I have a problem: My source mysql has a table that has been writing to, I use mysql cdc connec









![[Star Project] Little Hat Plane Battle (9)](/img/e3/c7d2728080bcdccc181a7e5c50ee6f.png)