Annuale Paga annualmente e ottieni 2 mesi gratis su ogni piano a pagamento. Vedi i piani
Accedi Inizia gratis

Consulente di refactoring

Input
Codice
function add(a, b) { return a + b; }
Risultato di esempio Creato il 27 ottobre 2026
function addNumbers(firstNumber: number, secondNumber: number): number {
  return firstNumber + secondNumber;
}
  • Added number parameter types to fix the implicit any parameters.
  • Restricted both operands to numbers, removing ambiguity between numeric addition and string concatenation.
  • Added an explicit number return type to document and enforce the function’s contract.
  • Renamed add, a, and b to addNumbers, firstNumber, and secondNumber for clearer intent.
Usa questo Consulente di refactoring Il modulo si apre compilato con gli input di questo esempio; cambia ciò che vuoi.