Avatar ·

Arrow function syntax with generics in TypeScript

Hi everyone! I'm new to TypeScript and I can't figure out the syntax for arrow functions when I need to use generics (generic types). \n\nIn regular functions, I write it like this — it works:\n\n```typescript\nfunction identity(arg: T): T {\n return arg;\n}\n```\n\nBut when I try to do the same with an arrow function, TypeScript throws errors. I've tried several options:\n\n```typescript\n// Option 1 - error\nconst identity = (arg: T): T => arg;\n\n// Option 2 - also doesn't work\nconst identity = (arg: T): T => arg;\n\n// Option 3 - complains about JSX\nconst identity = (arg: T): T => arg;\n```\n\nSpecifically in React components with JSX, I'm completely confused. When I write `` inside JSX, TypeScript thinks it's a JSX element, not a ge