RecipesChapter 9: The Standard Library and External Type Definitions

Explicitly Highlighting Unsafe Operations with Type Assertions and unknown

Recipe 9.2 from The TypeScript Cookbook

const ppl: Person[] = await fetch("/api/people").then((res) => res.json());
//    ^
// Type 'unknown' is not assignable to type 'Person[]'.ts(2322)
Open in TypeScript Playground →