Skip to content

Instantly share code, notes, and snippets.

@promer94
Last active June 15, 2022 17:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save promer94/b60f437330bc6e9b3adb2553578e7c06 to your computer and use it in GitHub Desktop.
Save promer94/b60f437330bc6e9b3adb2553578e7c06 to your computer and use it in GitHub Desktop.
TypeScript-类型编程

TS 类型编程



TS 核心优势

  • 类型帮助用户在编译期提前发现错误
  • 类型通过 IDE 极大提升了开发者体验
  • 类型能帮助开发者设计和完善程序

TS 类型系统

  • 类型会通过字面量自动推导
  • 类型不仅仅是标注 - 更是可计算的值
  • 类型一等公民
  • Creating Types from Types


useSWR.png


  • TS 的类型系统有非常强大的表现力,可以用于表达复杂逻辑 (图灵完备)
    • 泛型
      • 类似于变量声明
    • 条件类型
      • infer
      • distributive-conditional-types
  • 类型系统并不能解决所有的实际问题,要正确使用,不能拿着锤子找钉子

学习资料



Fun


感谢大家

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment