当前位置:网站首页>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 中的常用类型









边栏推荐
- 14 医疗挂号系统_【阿里云OSS、用户认证与就诊人】
- Cmooc Internet + education
- MySQL實戰優化高手08 生產經驗:在數據庫的壓測過程中,如何360度無死角觀察機器性能?
- NLP routes and resources
- MySQL实战优化高手11 从数据的增删改开始讲起,回顾一下Buffer Pool在数据库里的地位
- CAPL脚本中关于相对路径/绝对路径操作的几个傻傻分不清的内置函数
- A new understanding of RMAN retention policy recovery window
- MySQL combat optimization expert 12 what does the memory data structure buffer pool look like?
- Redis集群方案应该怎么做?都有哪些方案?
- Sichuan cloud education and double teacher model
猜你喜欢

C杂讲 文件 续讲

How to build an interface automation testing framework?

MySQL combat optimization expert 03 uses a data update process to preliminarily understand the architecture design of InnoDB storage engine

Contest3145 - the 37th game of 2021 freshman individual training match_ B: Password

If a university wants to choose to study automation, what books can it read in advance?

如何搭建接口自动化测试框架?

在CANoe中通过Panel面板控制Test Module 运行(初级)

The appearance is popular. Two JSON visualization tools are recommended for use with swagger. It's really fragrant

MySQL实战优化高手11 从数据的增删改开始讲起,回顾一下Buffer Pool在数据库里的地位

Write your own CPU Chapter 10 - learning notes
随机推荐
15 medical registration system_ [appointment registration]
MySQL combat optimization expert 05 production experience: how to plan the database machine configuration in the real production environment?
[Julia] exit notes - Serial
软件测试工程师发展规划路线
Configure system environment variables through bat script
MySQL real battle optimization expert 11 starts with the addition, deletion and modification of data. Review the status of buffer pool in the database
宝塔的安装和flask项目部署
软件测试工程师必备之软技能:结构化思维
CAPL script printing functions write, writeex, writelineex, writetolog, writetologex, writedbglevel do you really know which one to use under what circumstances?
MySQL ERROR 1040: Too many connections
颜值爆表,推荐两款JSON可视化工具,配合Swagger使用真香
Installation de la pagode et déploiement du projet flask
Southwest University: Hu hang - Analysis on learning behavior and learning effect
MySQL实战优化高手03 用一次数据更新流程,初步了解InnoDB存储引擎的架构设计
CDC: the outbreak of Listeria monocytogenes in the United States is related to ice cream products
Combined search /dfs solution - leetcode daily question - number of 1020 enclaves
The programming ranking list came out in February. Is the result as you expected?
Zsh configuration file
Download address of canoe, download and activation of can demo 16, and appendix of all canoe software versions
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?