当前位置:网站首页>TypeScript(零) —— 简介、环境搭建、第一个实例
TypeScript(零) —— 简介、环境搭建、第一个实例
2022-07-28 01:25:00 【前端杂货铺】
系列文章目录
TypeScript 简介
TypeScript 是微软开发的一个开源的编程语言,通过在 JavaScript 的基础上添加静态类型定义构建而成。
TypeScript 通过 TypeScript 编译器或 Babel 转译为 JavaScript 代码,可运行在任何浏览器,任何操作系统。
TypeScript 开发环境搭建
安装 node
可以去 node 官网自行下载所需要的版本
在 cmd 输入 node -v,输出版本号,则说明 node 已成功安装
node -v

安装 TypeScript
在 cmd 输入 npm i -g typescript,不报错则安装成功
npm i -g typescript

创建一个 TS 文件
创建一个文件夹,在文件夹里创建一个 .ts 文件

使用 tsc 对 ts 文件进行编译
打开终端 (Ctrl + ~)
命令行键入:tsc xxx

可以发现,ts 文件被编译并生成了对应的 js 文件开启监视:让 ts 文件改变后自动编译
tsc xxx -w
开启监视:

修改内容后自动编译:

在浏览器上运行文件
创建 index.html 文件,在 src 中写入 js 路径即可
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script src="01_helloTS.js"></script>
</body>
</html>
不积跬步无以至千里 不积小流无以成江海
点个专注不迷路,持续更新中…
边栏推荐
- [advanced ROS] Lecture 9 robot model motion based on rviz and arbotix control
- 基于stm32的恒功率无线充电
- CeresDAO:Ventures DAO的“新代言”
- Day6 函数和模块的使用
- Flex layout - fixed positioning + flow layout - main axis alignment - side axis alignment - expansion ratio
- JVM tuning -xms -xmx -xmn -xss
- "Risking your life to upload" proe/creo product structure design - seam and buckle
- How to put app on the app store?
- Canvas 从入门到劝朋友放弃(图解版)
- ERD online 4.0.0 free private deployment scheme
猜你喜欢

MySQL's way to solve deadlock - lock analysis of common SQL statements

Mysql Explain 详解(荣耀典藏版)

JS event loop synchronous task, asynchronous task (micro task, macro task) problem analysis
![[Yugong series] July 2022 go teaching course 019 - for circular structure](/img/40/b4e673de0462c3dd6ca8b8fb513914.png)
[Yugong series] July 2022 go teaching course 019 - for circular structure
![[understanding of opportunity -53]: Yang Mou stands up and plots to defend himself](/img/93/2f61993770d93d9adc80a9fa89e71c.jpg)
[understanding of opportunity -53]: Yang Mou stands up and plots to defend himself

Please, don't use the command line to configure MySQL master-slave replication. Isn't it fragrant to deploy with urlos interface?

基于stm32的恒功率无线充电

借助Elephant&nbsp;Swap打造的ePLATO,背后的高溢价解析

MySQL锁系列之锁算法详解(荣耀典藏版)

Xiaomi website homepage big module - small module + navigation (floating case)
随机推荐
第三章 队列
Necessary knowledge points of the original group
POC模拟攻击利器 —— Nuclei入门(一)
Pytorch optimizer settings
Common SQL statement query
Leetcode judge whether palindrome number
Three core issues of concurrent programming (glory Collection Edition)
How to put app on the app store?
[Yugong series] July 2022 go teaching course 019 - for circular structure
Share an esp32 relay
Canvas 从入门到劝朋友放弃(图解版)
QT implementation disable shortcut key
With elephant & nbsp; Eplato created by swap, analysis of the high premium behind it
[Star Project] small hat aircraft War (VI)
Manual installation of Dlib Library
From prediction to decision-making, Chapter 9 Yunji datacanvas launched the ylearn causal learning open source project
Day6 函数和模块的使用
探究flex-basis
Unity saves pictures to albums and rights management
Feign calls get and post records