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









边栏推荐
- 竞赛vscode配置指南
- MySQL combat optimization expert 07 production experience: how to conduct 360 degree dead angle pressure test on the database in the production environment?
- Why can't TN-C use 2p circuit breaker?
- Sed text processing
- Compress decompress
- Configure system environment variables through bat script
- MySQL combat optimization expert 09 production experience: how to deploy a monitoring system for a database in a production environment?
- 14 医疗挂号系统_【阿里云OSS、用户认证与就诊人】
- CAPL script pair High level operation of INI configuration file
- VH6501学习系列文章
猜你喜欢

MySQL combat optimization expert 12 what does the memory data structure buffer pool look like?

四川云教和双师模式

C杂讲 文件 续讲

CANoe不能自动识别串口号?那就封装个DLL让它必须行

解决在window中远程连接Linux下的MySQL
![[one click] it only takes 30s to build a blog with one click - QT graphical tool](/img/f0/52e1ea33a5abfce24c4a33d107ea05.jpg)
[one click] it only takes 30s to build a blog with one click - QT graphical tool

C miscellaneous shallow copy and deep copy

软件测试工程师必备之软技能:结构化思维

MySQL實戰優化高手04 借著更新語句在InnoDB存儲引擎中的執行流程,聊聊binlog是什麼?

Canoe cannot automatically identify serial port number? Then encapsulate a DLL so that it must work
随机推荐
MySQL storage engine
16 医疗挂号系统_【预约下单】
MySQL实战优化高手03 用一次数据更新流程,初步了解InnoDB存储引擎的架构设计
再有人问你数据库缓存一致性的问题,直接把这篇文章发给他
Super detailed steps to implement Wechat public number H5 Message push
MySQL的存储引擎
The appearance is popular. Two JSON visualization tools are recommended for use with swagger. It's really fragrant
CANoe下载地址以及CAN Demo 16的下载与激活,并附录所有CANoe软件版本
CAPL script pair High level operation of INI configuration file
A necessary soft skill for Software Test Engineers: structured thinking
MySQL实战优化高手09 生产经验:如何为生产环境中的数据库部署监控系统?
Carolyn Rosé博士的社交互通演讲记录
Solve the problem of remote connection to MySQL under Linux in Windows
Sichuan cloud education and double teacher model
CAPL 脚本打印函数 write ,writeEx ,writeLineEx ,writeToLog ,writeToLogEx ,writeDbgLevel 你真的分的清楚什么情况下用哪个吗?
A new understanding of RMAN retention policy recovery window
Compress decompress
max-flow min-cut
Sed text processing
Target detection -- yolov2 paper intensive reading