当前位置:网站首页>【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.
边栏推荐
- 【AppCube】数字孪生万物可视 | 联接现实世界与数字空间
- 自定义实现乘风破浪的小船
- error C2872: “flann”: 不明确的符号 解决方法
- Binary search tree (search binary tree) simulation implementation (there is a recursive version)
- 【多线程的相关内容】
- 二叉搜索树(搜索二叉树)模拟实现(有递归版本)
- 【输出一个整数的的每一位,由高到低输出。使用递归和不使用递归】
- 微信多开批处理(自动获取安装路径)
- 开源一夏 | 教你快速实现“基于Docker快速构建基于Prometheus的MySQL监控系统”
- 【JDBC以及内部类的讲解】
猜你喜欢
redis基础知识总结——数据类型(字符串,列表,集合,哈希,集合)
MapReduce中ETL数据清洗案例
The way of programmer architecture practice: how to design a sustainable evolution system architecture?
玉溪卷烟厂通过正确选择时序数据库 轻松应对超万亿行数据
怎么在外头使用容器里php命令
开源一夏 | 教你快速实现“基于Docker快速构建基于Prometheus的MySQL监控系统”
go——并发编程
再谈“雷克萨斯”安全装置失效!安全手册疑点重重,网友:细思极恐
混动产品谁更吃香,看技术还是看市场?
「全球数字经济大会」登陆 N 世界,融云提供通信云服务支持
随机推荐
深度学习经典网络 -- Inception系列(稀疏结构)
程序员架构修炼之道:软件架构基本概念和思维
成对连接点云分割
成为优秀架构师必备技能:怎样才能画出让所有人赞不绝口的系统架构图?秘诀是什么?快来打开这篇文章看看吧!...
三大产品力赋能欧萌达OMODA5
浪潮—英伟达打造元宇宙新方案,虚拟人的故事将再破你的认知
聊天app开发——防炸麦以及节省成本的内容鉴定方法
OS层面包重组失败过高,数据库层面gc lost 频繁
深度学习100例——卷积神经网络(CNN)实现服装图像分类
MATLAB程序设计与应用 2.6 字符串
程序员架构修炼之道:如何设计出可持续演进的系统架构?
DOM对象能干什么?
MATLAB程序设计与应用 2.7 结构数据与单元数据
孙宇晨式“溢价逻辑”:不局限眼前,为全人类的“星辰大海”大胆下注
完全背包问题的思路解析
MySQL database combat (1)
什么是IDE?新手用哪个IDE比较好?
面试一面
出色的移动端用户验证
白帽黑客与留守儿童破壁对“画”!ISC、中国光华科技基金会、光明网携手启动数字安全元宇宙公益展