LauraBeatris / typescript-learning-book

My learnings around TypeScript - From Type Transformations, Generics, Patterns, and much more

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TypeScript Logo

TypeScript Learning Book

Throughout my TypeScript journey, modules will be added with usage examples according to each topic on this repository.

Here you can refer to the modules structured by learning area, that can be used as examples for your learning journey as well.

All of the exercises and content here were consumed through the Total TypeScript course

References

Transformations

  • Inference Basics: Utilities and operators to define types based on the compiler inference.
  • Template Literals: From TypeScript 4.1, Template Literals help to create object types, split strings into tuples and other useful transformations.
  • Type Helpers: Building type helpers on top of the ones within the language, as well setting constraints that ensure the flexibility and reusability of types.
  • Unions and Indexing: Learn the difference between Unions and Discriminated Unions, how to access their properties with indexed access types and the usage of built-in utility types.
  • Conditional Types: Integrate conditional types along type helpers, as well as learning the use cases behind the infer keyword.
  • Mapped Types: Transform any type into and out of objects, unions, and tuples.

Generics

Advanced Patterns

  • Branded Types: Branded types allow us to create new types in TypeScript by adding a type tag to an existing underlying type. This type tag, also known as the "brand," distinguishes values of the branded type from other values of the same underlying type.
  • Globals: Use cases to define types in a global scope.
  • Type Predicates and Assertion Functions: Allow to customize TypeScript's control flow, and improve inference when used in combination with if statements.
  • Classes - Builder Pattern: Using classes and generics to build data structures and perform inference without type annotations from the user.
  • External Libraries: Understanding the flow of generics through an external library, and where external types come from.
  • Identity Functions: When and where to use identity functions for inference.

React with TypeScript

  • Advanced Props: Patterns to shape props to support multiple variants, share selected props between different components, use union types for conditional rendering, etc.
  • Generics with components: TypeScript generics are a key tool in creating flexible, reusable components and hooks in React.
  • Advanced Hooks: Concepts like returning read-only tuples from custom hooks and implementing function overloads for built-in hooks like useState.
  • Types Deep Dive: Understanding the various members of the React namespace, and how to use them to build better prop types.
  • Advanced Patterns: Learn patterns like Render Props and Higher Order Components, solving the forwardRef problem, and understanding the ‘as’ prop.
  • External Libraries: Understand how to use TypeScript with external libraries, such as creating type-safe form components with react-hook-form, and learn how to use third-party generics with react-select.

Common Errors

Exercises from the Solving TypeScript errors workshop.

About

My learnings around TypeScript - From Type Transformations, Generics, Patterns, and much more

License:MIT License


Languages

Language:TypeScript 100.0%