Functions in TypeScript
Typing Arrow Functions vs Function Declarations
Compare typing syntax, scope binding, hoists, generic syntax differences, and best practices for Arrow Functions vs Function Declarations in TypeScript.
Last Updated: July 29, 2026
•
10 min read
In TypeScript, both Function Declarations and Arrow Functions can be strongly typed, but they differ in type annotation syntax, generic syntax, this binding, and hoisting behavior.
1. Syntax Comparison
Function Declarations
Function declarations annotate parameter and return types inline in the header:Arrow Functions
Arrow functions can annotate parameter/return types inline, or utilize a separate Function Type Expression:2. Generics in Arrow Functions vs Declarations
When writing generic functions, arrow functions in JSX/TSX files require a trailing comma , after the type parameter so the compiler doesn't mistake the generic bracket for an HTML tag.
Generic Function Declaration
Generic Arrow Function in TSX Files
3. Key Differences Table
| Feature | Function Declarations | Arrow Functions |
|---|---|---|
| Hoisting | Hoisted to top of scope | Not hoisted (Temporal Dead Zone) |
this Binding | Dynamic (Call-site) | Lexical (Inherited from parent scope) |
Fake this Parameter | Supported (function(this: Context)) | Not Supported |
| Type Expression Assignment | Cannot be directly assigned a type alias | Can be assigned to a type alias |
| Generic TSX Syntax | | Requires in TSX files |
arguments Object | Accessible | Not Accessible |
4. When to Use Which Syntax
Use Function Declarations When:
this binding (e.g. DOM event listeners or class prototypes).Use Arrow Functions When:
.map(), .filter(), .reduce()).this context inside methods or timeouts.5. Interactive Code Playground
Compare function declaration vs arrow function syntax below:
6. Common Pitfalls & Edge Cases
const fn = (val: T) => val; inside a .tsx file results in a parse error: Unterminated JSX contents. Always write or in TSX files.7. Summary Checklist
this. to generic arrow functions in .tsx files.type Fn = (a: number) => string) work seamlessly with arrow functions.