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 };