TS2744

Type parameter defaults can only reference previously declared type parameters.

Broken Code ❌

type Result<Data, Error = Error> = { ok: true; data: Data } | { ok: false; error: Error };

This error occurs because the default type Error = Error is interpreted as referring to the second type parameter but you’re trying to default it to the global Error class. TypeScript doesn’t allow a type parameter default to refer to itself.

Fixed Code βœ”οΈ

Use a different name for the second type parameter to avoid confusion with the global Error type:

type Result<Data, E = Error> = { ok: true; data: Data } | { ok: false; error: E };