The Weird Parts of TypeScript 13 exercises

Excess Property Warnings in TypeScript

In this exercise, we're dealing with an options object along FetchOptions interface which specifies url, method, headers, and body:

interface FetchOptions {
url: string;
method?: string;
headers?: Record<string, string>;
body?: string;
const options = {
url: "

Loading exercise


00:00 In this exercise we have a const options object and this options object has URL, method, headers and search on it and we have the interface fetch options above which specifies URL, method, headers and body. Now we're expecting this search to be at least give us a warning

00:17 or something. There must be something going on because we have a myFetch function down below which has fetch options on it up here with URL, method, headers and body but when we call myFetch using our options which has this excess property of search

00:33 it's not erroring here. That's really weird. So why wouldn't TypeScript be complaining if an excess property was added onto this options when it shouldn't be there? Your job is to work out how we can restructure this code to make this work like what annotations

00:51 can we add or whether we can move this object into a different sort of setting and get a more descriptive error here and just kind of try to wrap your brain around why this would be error why this wouldn't be erroring in the first place. Good luck!