Why is the SupposedId
type below not considered a type identity?
I'm getting an error in Typescript saying that
Type 'T' is not assignable to type 'SupposedId<T>'
.
How is it possible that T
cannot be assigned to either T
or T
? What am I missing?
type SupposedId<T> = T extends object ? T : T;
function makeId<T>(test: T): SupposedId<T> {
return test // <- Type 'T' is not assignable to type 'SupposedId<T>'
}