TypeScript 7 · Types
Write a generic function
Keep the relationship between input and output types.
function first<T>(items: T[]): T | undefined {
return items[0];
}
Official TypeScript 7 documentation
TypeScript 7 · Types
Keep the relationship between input and output types.
function first<T>(items: T[]): T | undefined {
return items[0];
}
Official TypeScript 7 documentation
Was this page helpful?