TypeScriptAsync, Promises & Error Handling Types

78 items

1

Typing .then() and .catch() Handlers

Flashcard
2

Typing for-await-of Loop Variables

Flashcard
3

Why Promise Rejections Aren't Typed

Slides / Video
4

Void-Returning Promises and Fire-and-Forget

Slides / Video
5

Typing Promise Executor Callbacks

Slides / Video
6

Result Union Types for Success and Failure

Slides / Video
7

Custom Error Classes and Typing Them

Slides / Video
8

The useUnknownInCatchVariables Flag

Slides / Video
9

Narrowing unknown Errors in catch

Slides / Video
10

Catch Clause Errors Are unknown

Slides / Video
11

Typing race, allSettled, and any

Slides / Video
12

Typing Promise.all Tuple Results

Slides / Video
13

Typing await and Unwrapped Values

Slides / Video
14

The Promise<T> Type Parameter

Slides / Video
15

Async Function Return Types

Slides / Video
16

catch Variable Is unknown

Code Quiz
17

Typing catch Handler Parameter

Code Quiz
18

Chained then Return Value

Code Quiz
19

Typing the Executor Callback

Code Quiz
20

Reading allSettled Results

Code Quiz
21

instanceof Error Narrowing

Code Quiz
22

Narrowing an unknown Error

Code Quiz
23

Custom Error Class Typing

Code Quiz
24

Wrong Resolved Value Type in Promise

Code Quiz
25

Typing an async Arrow Function

Code Quiz
26

Iterating an AsyncIterable

Code Quiz
27

Typing an async Generator

Code Quiz
28

Discriminated Result Type

Code Quiz
29

async Function Returning void

Code Quiz
30

Always-Throwing Function Return Type

Code Quiz
31

Promise Type Has One Parameter

Code Quiz
32

Floating Promise Not Awaited

Code Quiz
33

Promise.all Result Tuple Types

Code Quiz
34

Typing Promise.resolve and reject

Code Quiz
35

Awaiting a Non-Promise Value

Code Quiz
36

await Outside an async Function

Code Quiz
37

Awaiting Unwraps the Value Type

Code Quiz
38

Async Function Return Type

Code Quiz
39

Typing a Promise with Promise<T>

Code Quiz
40

Promise.race Return Type

Code Quiz
41

Typing Rejected Promise Values

Quiz
42

Custom Error Class Typing

Quiz
43

instanceof Error Narrowing in catch

Quiz
44

Narrowing Errors in catch Blocks

Quiz
45

useUnknownInCatchVariables Flag

Quiz
46

catch Clause Variable Typing

Quiz
47

Promise Executor and resolve/reject Typing

Quiz
48

Typing Promise.allSettled Result Shape

Quiz
49

Typing Promise.race and Promise.any

Quiz
50

Typing Promise.all Result Tuples

Quiz
51

Promise<T> Type Annotation

Quiz
52

Typing async Function Return Values

Quiz
53

Floating Promise Concerns

Quiz
54

void vs Promise<void> in Async Contexts

Quiz
55

Typing Callback-to-Promise Wrappers

Quiz
56

for await...of Element Typing

Quiz
57

Async Generators and AsyncIterable Types

Quiz
58

Typing then/catch Callback Chains

Quiz
59

Result / Either Pattern for Typed Errors

Quiz
60

await Expression Result Types

Quiz
61

never Return Type for Throwing Functions

Quiz
62

Void vs Undefined Return in Async Callbacks

Flashcard
63

Narrowing Caught Errors with instanceof

Flashcard
64

Chaining Promises and Return Type Flow

Flashcard
65

Typing Promise Resolution Values

Flashcard
66

useUnknownInCatchVariables Flag

Flashcard
67

Errors Are Typed as unknown in catch

Flashcard
68

The Promise<T> Type

Flashcard
69

The never Type in Throwing Functions

Flashcard
70

Result/Either Pattern for Error Handling

Flashcard
71

Typing Promise.race and Promise.allSettled

Flashcard
72

Custom Error Class Typing

Flashcard
73

Typing the Promise Executor Callbacks

Flashcard
74

Explicitly Annotating async Return Types

Flashcard
75

PromiseSettledResult Types

Flashcard
76

Awaiting a Promise and the Resulting Type

Flashcard
77

Typing Promise.all Results as a Tuple

Flashcard
78

async Function Return Type Inference

Flashcard
Code QuizIntermediate

Promise Type Has One Parameter

A Promise's type only encodes the resolved value, never the rejection reason.

Codetypescript
function fetchName(): Promise<string, Error> {
  return fetch("/name").then(r => r.text());
}

What is the bug in this return type annotation?