No BS TS, 18 Conditional Types in Typescript
Turns out you can define types conditionally based on the type check against a different type. Let s try it out on a fetch function that optionally takes a callback and can return either a void or a promise based on that callback. 00:00 Introduction 00:18 What are conditional types 02:15 Importing libraries 03:15 fetchPokemon with conditionals 08:23 fetchPokemon with overloading 11:14 Outroduction Conditional Types page: Code: If you liked this video, buy me a coffee What s my theme Night Wolf dark blue What s that font MonoLisa Jack is also on the React Round Up podcast: . .., JackHerrington, typescript, typescriptconditionaltypes, conditionaltypesintypescript, typescriptconditionalfetch, typescriptconditionalfunctionoverloading, conditionalfetchintypescript, NoBSTS18ConditionalTypes, ConditionalTypesinTypescript, NoBSTS 20210519 jdzLpEnRAqg
|
|