Reputation: 29168
Could someone help me understand what T = {}
means in the following typescript interface? I cannot find docs indicating such usage. How is it different from just T
?
interface CustomProps<T = {}> {
itemId: string;
id: string;
}
Upvotes: 1
Views: 64
Reputation: 97120
They're called generic parameter defaults and were introduced in TypeScript 2.3. You can find the documentation here.
For your example, it means that if no type parameter is specified, it will default to {}
, which is commonly referred to as the empty object type.
Upvotes: 2