Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TS学习记录 #70

Open
4 of 8 tasks
wuyanqian0503 opened this issue Aug 18, 2021 · 1 comment
Open
4 of 8 tasks

TS学习记录 #70

wuyanqian0503 opened this issue Aug 18, 2021 · 1 comment

Comments

@wuyanqian0503
Copy link
Owner

wuyanqian0503 commented Aug 18, 2021

学习目标

  • TS和JS的区别
  • TS中有哪些类型
  • TS的泛型实践
  • TS类型工具的使用和实现
  • TS的编译结果是怎样的
  • TS的类型保护怎么做
  • 区别void、never、any等类型,和具体使用场景
  • type和interface的区别
@wuyanqian0503
Copy link
Owner Author

TS和JS的区别

最大的区别就是TS在JS的基础上提供了类型系统,并且通过这个类型系统支持了静态类型校验。

由于JS是动态类型语言,松散的类型导致代码容易出现运行错误。TS通过静态类型校验,在运行代码前对代码进行类型校验,测试代码的正确性,提高代码的可读性以及可维护性。

TS中有哪些类型

  • 原始类型:string、number、boolean
  • 特殊类型:null、undefined、any、void(函数没有返回值)、never(永远不存在值,类型保护)
  • 元祖类型:已知元素类型和长度的数组
  • 枚举类型:数字枚举、字符串枚举
  • 高级类型:联合类型、交叉类型

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant