The Problem with Untyped fetch
What you'll learn: Why TypeScript loses all type safety when you use the built-in fetch API, even though fetch is fully typed in the browser and Node.js.
The Type Safety Black Hole
When you call fetch() in TypeScript, you get back a Promise<Response>. So far, so good—TypeScript knows you have a Response object. But here's where things fall apart:
When you call .json() on that Response, TypeScript gives you back Promise<any>.
That's right: any. All your type safety just vanished.
Why This Happens
The fetch API is a generic network tool. It has no idea what data structure lives on the other end of that HTTP request. You might be fetching user data, product listings, authentication tokens, or even plain text. TypeScript can't magically know what your API returns.
So the signature looks like this:
interface Response {
json(): Promise<any>;
text(): Promise<string>;
// ... other methods
}
The json() method must return any because it could be literally anything: an object, an array, a string, a number, null, or even deeply nested structures.
The Consequence
This means every API call becomes an untyped boundary in your application:
const response = await fetch('/api/users');
const data = await response.json();
// data is `any` - no autocomplete, no safety
You've lost autocomplete, refactoring safety, and compile-time guarantees exactly where you need them most—at the boundary between your application and external data.
Key Takeaway: fetch returns Promise<Response> with type safety, but .json() returns Promise<any>, creating a dangerous type-safety gap at every API boundary in your application.