Annotate parameters and return values.
Section: Functions and Parameters
Type a function
typescript
typescript
function add(a: number, b: number): number {
return a + b;
}Explanation
Return annotations can improve clarity even when TypeScript can infer them.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Functions and Parameters
Use default parameters
Provide a default value and keep a concrete type.
Declare function overloads
Expose multiple call signatures with one implementation.