Assertion Functions or Assertion Guards - TypeScript Narrowing #5

Опубликовано: 14 Октябрь 2024
на канале: Lucas Paganini
1,601
63

The fifth video in our TypeScript Narrowing series. In this video, we cover Assertion Functions (also known as Assertion Guards).

📚 Read the article: https://www.lucaspaganini.com/academy...
🚨 Subscribe to the newsletter: https://www.lucaspaganini.com/newsletter

📧 Email: [email protected]
🐦 Twitter:   / lucaspaganini  
📸 Instagram:   / lucaspaganini  

----------

CHAPTERS
0:00 Introduction
0:27 Assertion Functions vs Type Guards
1:29 Early Exits
2:17 Issues with Control Flow Analysis
3:21 Function Expressions with Predefined Types
4:04 Assertions without a Type Predicate
4:24 Conclusion

RELATED
1. Early Returns/Exits - Code Patterns in JavaScript:    • Early Returns/Exits - Code Patterns i...  
2. TypeScript Narrowing Series:    • What is a Type Guard - TypeScript Nar...  
3. TypeScript Narrowing Part 1 - What is a Type Guard:    • What is a Type Guard - TypeScript Nar...  
4. TypeScript Narrowing Part 2 - Type Guard Operators:    • Fundamental Type Guards - TypeScript ...  
5. TypeScript Narrowing Part 3 - Custom Type Guards:    • Custom Type Guards - TypeScript Narro...  
6. TypeScript Narrowing Part 4 - Discriminated Unions or Tagged Unions Types:    • Discriminated Unions or Tagged Unions...  

REFERENCES
1. Assertion Functions (TypeScript Documentation): https://www.typescriptlang.org/docs/h...
2. Pull Request - Assertion Functions (TypeScript Github Repository): https://github.com/microsoft/TypeScri...
3. Pull Request - Error Messages for Assertion Functions that couldn't be Control Flow Analysed (TypeScript Github Repository): https://github.com/microsoft/TypeScri...
4. Issue - Assertion Functions and Function Expressions (TypeScript Github Repository): https://github.com/microsoft/TypeScri...
5. Code Examples (Lucas Paganini): https://www.typescriptlang.org/play?#...

#typescript #programming #webdevelopment