Function parameters MUST have explicit type annotations.
Function return types MUST be explicitly declared.
Local variables SHOULD use type inference where the type is obvious.
Example (Correct):
// Explicit parameter and return types
function calculateDiscount(price: number, percent: number): number {
return price * (1 - percent / 100)
}
// Type inference for obvious cases
const discount = calculateDiscount(100, 20)
Example (Incorrect):
// Missing return type
function calculateDiscount(price: number, percent: number) {
return price * (1 - percent / 100)
}
// Unnecessary type annotation
const discount: number = calculateDiscount(100, 20)