当前位置:网站首页>Typescript入门教程(B站黑马程序员)
Typescript入门教程(B站黑马程序员)
2022-07-06 09:10:00 【巨人张】
视频链接:https://www.bilibili.com/video/BV14Z4y1u7pi?p=1
1. TypeScript 介绍
1.1 TypeScript 是什么

1.2 TypeScript 为什么要为 JS 添加类型支持?

1.3 TypeScript 相比 JS 的优势

2. TypeScript 初体验
2.1 安装编译 TS 的工具包

2.2 编译并运行 TS 代码

2.3 简化运行 TS 的步骤

- 注意:若
ts-node hello.ts执行报错,需要先执行命令tsc --init创建一个 tsconfig.json 文件,该文件是 TypeScript 项目的配置文件 - tsconfig.json 包含 TypeScript 编译的相关配置,通过更改编译配置项,我们可以让 TypeScript 编译出 ES6、ES5、node 的代码。
3. TypeScript 常用类型

3.1 类型注解

3.2 常用基础类型概述

3.3 原始类型

3.4 数组类型

3.5 类型别名

3.6 函数类型


- 如果函数没有返回值,那么,函数返回值类型为:void。


3.7 对象类型


3.8 接口



3.9 元组

3.10 类型推论

3.11 类型断言


3.12 字面量类型


3.13 枚举





3.14 any 类型

3.15 typeof

4. TypeScript 高级类型

4.1 class 类




- 类继承的两种方式:1 extends(继承父类) 2 implements(实现接口)。


- 类成员可见性:可以使用 TS 来控制 class 的方法或属性对于 class 外的代码是否可见。
- public

- protected

- private

- readonly

4.2 类型兼容性







4.3 交叉类型


4.4 泛型













Partial<Type>
Readonly<Type>
Pick<Type, Keys>
Record<Keys, Type>

4.5 索引签名类型

4.6 映射类型





5. TypeScript 类型声明文件

5.1 TS 中的两种文件类型

5.2 类型声明文件的使用说明







6. 在 React 中使用 TypeScript

6.1 使用 CRA 创建支持 TS 的项目



6.2 TS 配置文件 tsconfig.json


6.3 React 中的常用类型









边栏推荐
- Installation of pagoda and deployment of flask project
- Zsh configuration file
- MySQL combat optimization expert 05 production experience: how to plan the database machine configuration in the real production environment?
- Tianmu MVC audit I
- MySQL实战优化高手06 生产经验:互联网公司的生产环境数据库是如何进行性能测试的?
- How to build an interface automation testing framework?
- Simple solution to phpjm encryption problem free phpjm decryption tool
- CDC: the outbreak of Listeria monocytogenes in the United States is related to ice cream products
- Configure system environment variables through bat script
- [CV] target detection: derivation of common terms and map evaluation indicators
猜你喜欢
随机推荐
寶塔的安裝和flask項目部署
CANoe仿真功能之自动化序列(Automation Sequences )
简单解决phpjm加密问题 免费phpjm解密工具
Several silly built-in functions about relative path / absolute path operation in CAPL script
MySQL real battle optimization expert 08 production experience: how to observe the machine performance 360 degrees without dead angle in the process of database pressure test?
Automation sequences of canoe simulation functions
Solve the problem of remote connection to MySQL under Linux in Windows
MySQL实战优化高手11 从数据的增删改开始讲起,回顾一下Buffer Pool在数据库里的地位
15 medical registration system_ [appointment registration]
MySQL ERROR 1040: Too many connections
MySQL combat optimization expert 10 production experience: how to deploy visual reporting system for database monitoring system?
西南大学:胡航-关于学习行为和学习效果分析
美新泽西州州长签署七项提高枪支安全的法案
MySQL实战优化高手06 生产经验:互联网公司的生产环境数据库是如何进行性能测试的?
好博客好资料记录链接
Several errors encountered when installing opencv
MySQL ERROR 1040: Too many connections
[NLP] bert4vec: a sentence vector generation tool based on pre training
Implement context manager through with
Sed text processing







![[Julia] exit notes - Serial](/img/d0/87f0d57ff910a666fbb67c0ae8a838.jpg)

