Debugging Errors: Unintuitive Error Message
This lesson walks you through debugging a complex and unintuitive error message.
We'll cover the following...
Overview
In this example, we’ll look at a complex and unintuitive error message.
Below you can find a short piece of code using the RxJS library. In short, RxJS is a library for creating and manipulating streams of data. The piece of code below is supposed to create a stream of five numbers, map it into a stream of those numbers multiplied by two, and finally return a stream that emits only the last number.
const source = of(1, 2, 3, 4, 5).pipe(
map(x => x * 2),
last // 🔴 Error!
);
When compiled, this code will yield a large and complex error message.
Argument of type '{ <T, D = T>(predicate?: null | undefined, defaultValue?: D | undefined): OperatorFunction<T, T | D>; <T, S extends T>(predicate: (value: T, index: number, source: Observable<T>) => value is S,
...