Skip to content

theishu4/advance-typescript

Repository files navigation

1. Type Transform Workshop

1. Inference Basics

  1. ReturnType<> and Parameters<>
  2. Extracting type from tuples
  3. Awaited<>: Extract a Promise result
  4. Create a Union type from an Object keys

2. Union and Indexing

  1. Extract from a union
  2. Exclude from a union
  3. Index Access
  4. Discriminated union to discriminator
  5. Extract specific member from a union with index access
  6. Get All of an object value
  7. Create Union out of array values
  8. Extract type of element of an array

3. Template literals

  1. Only allow specified string pattern
  2. Extract Union Strings Matching a Pattern
  3. Create a Union of Strings with All Possible Permutations of Two Unions
  4. Splitting A String into a Tuple
  5. Create an Object Whose Keys Are Derived From a Union

3.5 Type helpers pattern

  1. Create Functions that Return Types
  2. Ensure Type Safety in a Type Helper
  3. Create Type Helper with multiple parameter
  4. Optional Type Parameters with default type
  5. Functions as Constraints for Type Helpers
  6. Constraining Types for Anything but null or undefined
  7. Constraining Type Helpers to Non Empty Arrays

4. Conditional Types and Infer

  1. Add Conditional Logic to a Type Helper
  2. Nested logic in a Type Helper
  3. Inferring Elements Inside a Conditional with Infer
  4. Extract Type Arguments to Another Type Helper
  5. Extract Parts of a String with a Template Literal
  6. Extract the Result of an Async Function
  7. Extract the Result From Several Possible Function Shapes
  8. Distributivity in Conditional Types

5. Key Remapping

  1. Map Over a Union to Create an Object
  2. Mapped Types with Objects
  3. Conditionally Extract Properties from Object
  4. Map a Discriminated Union to an Object
  5. Map an Object to a Union of Tuples
  6. Transform an Object into a Union of Template Literals
  7. Transform a Discriminated Union into a Union

6. Challenges

  1. Transform Dynamic Path Parameters from Strings to Objects
  2. Transform an Object into a Discriminated Union
  3. Transform a Discriminated Union with Unique Values to an Object
  4. Construct a Deep Partial of an Object

2. Typescript Generics Workshop

1. Generics Intro

  1. Typing function: Return what I pass in
  2. Restricting Type using Generics Constraints
  3. Multiple Type Parameters
  4. Approaches for Typing Object Parameters
  5. Generics in Classes
  6. Generic Mapper Function

2. Passing Type Arguments

  1. Add Type Parameters to a Function
  2. Infer Types from Type Arguments
  3. Strongly Type a Reduce Function
  4. Use Generics to Type a Fetch Request

3. Art of Type Arguments

  1. Generics at Different Levels
  2. Typed Object Keys
  3. Understand Literal Inference in Generics
  4. Understand Generic Inference When Using Objects as Arguments
  5. Inferring Literal Types from any Basic Type
  6. Infer the Type of an Array Member
  7. Generics in a Class Names Creator

4. Generics Advanced

  1. Generics with Conditional Types
  2. Fixing Errors in Generic Functions
  3. Generic Function Currying
  4. Generic Interfaces with Functions
  5. Spotting Useless Generics
  6. Spotting Missing Generics
  7. Refactoring Generics for a Cleaner API
  8. The Partial Inference Problem

5. Function Overloads

  1. What is a Function Overload --> issue
  2. Function Overloads vs Conditional Types
  3. Debugging Overloaded Functions
  4. Function Overloads vs Union Types
  5. Generics in Function Overloads
  6. Solving an Inference Mystery
  7. Use Function Overloads to Infer Initial Data
  8. The Instantiated with Subtype Error

6. Challenges

  1. Make An Infinite Scroll Function Generic with Correct Type Inference
  2. Create a Function with a Dynamic Number of Arguments
  3. Create a Pick Function
  4. Create a Form Validation Library
  5. Improve a Fetch Function to Handle Missing Type Arguments
  6. Typing a Function Composition with Overloads and Generics
  7. Build an Internationalization Library

3. Advanced Patterns

1. Branded Types

  1. What is a Branded type?
  2. Form Validation with Branded Types
  3. Using Branded Types as Entity Ids
  4. Creating Reusable Validity Checks with Branded Types and Type Helpers
  5. Creating Validation Boundaries with Branded Types
  6. Using Index Signatures with Branded Types

2. Globals

  1. TypeScript s Global Scope
  2. 💎 Add Functionality to Existing Global Interfaces
  3. Add Types to Properties of Global Namespaced Interfaces
  4. Collocating Types for Global Interfaces

3. Type Predicates Assertion Function

  1. Filtering with Type Predicates
  2. Checking Types with Assertion Functions
  3. 💎 Avoiding TypeScript s Most Confusing Error
  4. Combining Type Predicates with Generics
  5. Combining Brands and Type Predicates
  6. Combining Brands with Assertion Functions

4. Classes

  1. Classes as Types and Values
  2. 💎❓ Dive into Classes with Type Predicates
  3. Assertion Functions and Classes
  4. Class Implementation Following the Builder Pattern Explanation
  5. 👇Create a Type Safe Map with the Builder Pattern
  1. Importance of default generic
  2. Building Chainable Middleware with the Builder Pattern

5. External Libraries

  1. Extract Types to Extend an External Library
  2. Finding Proper Type Arguments and Generics with Lodash
  3. Add Query Params to an Express Request
  4. Create a Runtime and Type Safe Function with Generics and Zod
  5. Override External Library Types

6. Identity Function

  1. Identity Functions as an Alternative to the as const
  2. Add Constraints to an Identity Function
  3. Specifying Where Inference Should Not Happen
  4. Find the Generic Flow of an Identity Function
  5. Reverse Mapped Types

7. Challenges:

  1. Merge Dynamic Objects with Global Objects
  2. Narrowing with an Array
  3. Create a Type Safe Request Handler with Zod and Express
  4. Building a Dynamic Reducer

| Notes

Difference between Interface and types

  1. Interface support declaration merging but type not.
  2. type supporting object remapping but interface not.

About

Become TypeScript wizard...

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published