[推薦] 6 Advanced TypeScript Tricks

Source

https://medium.com/@mvsg/6-advanced-typescript-tricks-for-clean-code-90cee774dbf3 10min

Summary

分別羅列以下幾種方式

  1. Advanced Types: Mapped Types & Conditional Types
  2. Decorators: Class、Method、Property & Parameter Decorators
  3. Namespaces: grouping related code
  4. Mixins: compose classes, not inheritance, kind like trait in PHP
  5. Type Guards: use is keyword on function parameters, then caller can use dot notation
  6. Utility Types: Partial, Pick, Readonly, Omit
cmd + /