ILD

typescript introduction
作者:Yuan Jianpeng 邮箱:yuanjp89@163.com
发布时间:2024-4-21 站点:Inside Linux Development

typescript是微软开发的开源编程语言,它在2012年首次发布。typescript是javascript的超集。typescript没有直接运行环境,typescript的目的还是产生javascript。typescript通过tsc编译器生成javascript。


typescript的重要特性是添加了静态类型,如下:

let age: number = 18


.ts编译成.js,node.js集成了tsc,Fedora安装方法:

$ sudo dnf install nodejs


运行node.js

$ node -v

v16.18.1


node包管理工具npm

$ npm -v

8.19.2


使用npm安装typescript:

$ sudo npm install -g typescript


typescript编译器tsc应该好了:

$ tsc -v

Version 5.4.5


使用tsc编译hello.ts

1
2
3
4
5
6
7
$ cat hello.ts
let age : number = 12
 
$ tsc hello.ts
 
$ cat hello.js 
var age = 12;



https://www.bilibili.com/video/BV1jP41177p4/?vd_source=8289095406b1f446c9260820f19f84a9


Copyright © linuxdev.cc 2017-2024. Some Rights Reserved.