Too Many Parameters (ARCH3181)
Esta página aún no está disponible en tu idioma.
Key typescript.quality.too-many-parameters · Severity warning · Category quality
Functions with many parameters are easy to misorder at the call site and hard to read. Related parameters should be grouped into a parameter object, or dependencies injected.
Incorrect
Section titled “Incorrect”function createUser( name: string, email: string, age: number, country: string, city: string, zip: string, isAdmin: boolean, newsletter: boolean) { // ...}Correct
Section titled “Correct”interface CreateUserInput { name: string; email: string; age: number; address: { country: string; city: string; zip: string }; isAdmin: boolean; newsletter: boolean;}
function createUser(input: CreateUserInput) { // ...}Group related parameters into a single parameter (options) object.