当前位置:网站首页>【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.
边栏推荐
- numpy
- Programmers architecture practice way: software architecture basic concepts and thinking
- Spinner文字显示不全解决办法
- 请问应该用什么关键字将内容主题设置为 dark 呢
- Polymorphism in detail (simple implementation to buy tickets system simulation, covering/weight definition, principle of polymorphism, virtual table)
- 跨域问题的分析
- 【JDBC以及内部类的讲解】
- 聊天app开发——防炸麦以及节省成本的内容鉴定方法
- 程序员架构修炼之道:如何设计出可持续演进的系统架构?
- 完全背包问题
猜你喜欢
随机推荐
【JDBC以及内部类的讲解】
Why is the new earth blurred, in-depth analysis of white balls, viewing pictures, and downloading problems
4G采集ModbusTCP转JSON接MQTT云平台
跨域问题的分析
玉溪卷烟厂通过正确选择时序数据库 轻松应对超万亿行数据
图新地球为什么很模糊,白球、看图、下载问题深度剖析
synchronized
STM32入门开发 介绍SPI总线、读写W25Q64(FLASH)(硬件+模拟时序)
Analysis of the idea of the complete knapsack problem
CADEditorX ActiveX 14.1.X
怎么在外头使用容器里php命令
What is the IDE?Novice with which the IDE is better?
BPMN和DMN基本概念和使用案例
Activiti产生的背景和作用
完全背包问题的思路解析
如何通过DBeaver 连接 TDengine?
Who is more popular for hybrid products, depending on technology or market?
开源一夏 | 教你快速实现“基于Docker快速构建基于Prometheus的MySQL监控系统”
ETL data cleaning case in MapReduce
4 g acquisition ModbusTCP turn JSON MQTT cloud platform