当前位置:网站首页>一文让你搞懂什么是TypeScript
一文让你搞懂什么是TypeScript
2022-07-28 18:15:00 【前端小白在前进】
博主最近进入了typescript的学习,因此创建一个专栏,专门给大家分享一下自己在学习ts的一些知识总结和一些自己的感悟:
专栏 ===> typescript入门到拔高
TypeScript是什么

TypeScript简介
- TypeScript是JavaScript的超集。
- 它对JS进行了扩展,向JS中引入了类型的概念,并添加了许多新的特性。
TS代码需要通过编译器编译为JS,然后再交由JS解析器执行。- TS完全兼容JS,换言之,任何的JS代码都可以直接当成JS使用。
- 相较于JS而言,TS拥有了静态类型,更加严格的语法,更强大的功能;TS可以在代码执行前就完成代码的检查,减小了运行时异常的出现的几率;
TS代码可以编译为任意版本的JS代码,可有效解决不同JS运行环境的兼容问题;同样的功能,TS的代码量要大于JS,但由于TS的代码结构更加清晰,变量类型更加明确,在后期代码的维护中TS却远远胜于JS。
TypeScript增加了什么?

TypeScript 开发环境搭建
- 下载Node.js
大家可以去node.js的官网下载node.js ==> node.js官网
安装Node.js
使用npm全局安装typescript
1. 进入命令行 2. 输入:npm i -g typescript创建一个ts文件


使用tsc对ts文件进行编译
1. 进入命令行 2. 进入ts文件所在目录 3. 执行命令:tsc xxx.ts



到这里我们可以发现,我们已经将ts文件编译出来了,自动生成了ts文件
小结
我对于ts的理解就是,
ts其实就是严格版本的js,在我们日常开发中,js代码虽然书写方便,但是代码存在不严谨的情况,ts很好的解决了这个问题,这仅仅是第一篇文章,相信好多小伙伴们对ts的好处还没有充分的了解,关注我的专栏,慢慢让大家对ts有更深刻的见识。
边栏推荐
- Sequential linear table - practice in class
- 83.(cesium之家)cesium示例如何运行
- [C language] Pointer elementary knowledge points
- Quick sort template
- C language array and bubble sort
- Two methods to judge the size end
- Return and job management of saltstack
- C语言数据 3(1)
- Kubeedge releases white paper on cloud native edge computing threat model and security protection technology
- 9. Pointer of C language (3) classic program, exchange the value of two numbers for deep analysis, (easy to understand), are formal parameters and arguments a variable?
猜你喜欢

Saltstack advanced

Read how to deploy highly available k3s with external database

KubeEdge发布云原生边缘计算威胁模型及安全防护技术白皮书

Can China make a breakthrough in the future development of the meta universe and occupy the highland?

C+ + core programming

JVM (24) -- performance monitoring and tuning (5) -- Analyzing GC logs

为什么客户支持对SaaS公司很重要?
![[C language] Pointer advanced knowledge points](/img/8f/0057243c603ddfe20381c9bd446f03.png)
[C language] Pointer advanced knowledge points

Solve the cookie splitting problem (DP)

2. Floating point number, the difference between float and double in C language and how to choose them
随机推荐
1. C language variable type, global variable, local variable
Intermediate soft test (system integration project management engineer) high frequency test site
Introduction to seven kinds of polling (practice link attached)
长轮询,iframe和sse三种web消息实时推送demo实践
The results of the second quarter online moving people selection of "China Internet · moving 2022" were announced
Raspberry pie 4B parsing PWM
Basic knowledge of communication network 01
C language operators and input and output
What is the process of swing event processing?
一文读懂如何部署具有外部数据库的高可用 K3s
Raspberry pie creation self start service
C语言数据 3(2)
WPF--实现WebSocket服务端
[C language] shutdown game [loop and switch statement]
1、 Relationship among CPU, memory and hard disk
[C language] Pointer elementary knowledge points
私有化部署的即时通讯平台,为企业移动业务安全保驾护航
Raspberrypico analytic PWM
Token verification program index.php when configuring wechat official account server
Maximum exchange [greedy thought & monotonic stack implementation]