当前位置:网站首页>【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.
边栏推荐
- MATLAB程序设计与应用 2.7 结构数据与单元数据
- This article understands the process from RS485 sensor to IoT gateway to cloud platform
- Babbitt | Metaverse daily must-read: Players leave, platforms are shut down, and the digital collection market is gradually cooling down. Where is the future of the industry?...
- 三大产品力赋能欧萌达OMODA5
- 【AppCube】数字孪生万物可视 | 联接现实世界与数字空间
- Machine Learning Overview
- Win10/11 删除文件资源管理器左侧栏目文件夹
- 面试官:工作两年了,这么简单的算法题你都不会?
- build --repot
- synchronized
猜你喜欢

go——并发编程

ETL data cleaning case in MapReduce

再谈“雷克萨斯”安全装置失效!安全手册疑点重重,网友:细思极恐

MySQL数据库基本使用

MySQL数据库高级使用

孙宇晨式“溢价逻辑”:不局限眼前,为全人类的“星辰大海”大胆下注

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!...

What is the relationship between The Matrix and 6G?

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!...

机器学习概述
随机推荐
pixel手机升系统
玉溪卷烟厂通过正确选择时序数据库 轻松应对超万亿行数据
开源一夏 | 教你快速实现“基于Docker快速构建基于Prometheus的MySQL监控系统”
三大产品力赋能欧萌达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!...
[Star Project] Little Hat Plane Battle (9)
Mysql OCP 73 questions
numpy
【JDBC以及内部类的讲解】
后台图库上传功能
BPMN和DMN基本概念和使用案例
MapReduce中ETL数据清洗案例
深度学习100例——卷积神经网络(CNN)实现服装图像分类
ARIMA实现(亲测可用)
LeetCode第三题(Longest Substring Without Repeating Characters)三部曲之二
「全球数字经济大会」登陆 N 世界,融云提供通信云服务支持
混动产品谁更吃香,看技术还是看市场?
VL53L0X V2激光测距传感器 采集距离数据串口输出
请问应该用什么关键字将内容主题设置为 dark 呢
Web Server 设置缓存响应字段的一些推荐方案