Expected 1 arguments, but got 0 is TypeScript enforcing a function's declared arity — the number of parameters it expects — at every call site, catching calls that don't supply enough arguments (or supply too many) before your code ever runs and produces undefined-related bugs downstream.
This error means you called a function with a different number of arguments than its type signature declares as required — TypeScript treats parameters without a default value or an explicit ? optional marker as mandatory, and any call site not supplying all of them fails type checking.
Why This Error Happens
Every function parameter in TypeScript is required by default unless marked optional (param?: Type) or given a default value (param: Type = defaultValue). This error surfaces most often after refactoring a function's signature (adding a new required parameter) without updating every existing call site, or when calling a function whose signature you assumed was more permissive than it actually is.
Reproducing the Error
A function signature change breaking an existing call:
function createUser(name: string, email: string) {
return { name, email, createdAt: new Date() };
}
createUser("Alex");
// Error: Expected 2 arguments, but got 1.
The function requires both name and email; calling it with only one argument fails, exactly as it should — this is TypeScript catching a call site that wasn't updated after the signature changed.
Core Concepts Behind This Error
Parameters are required by default, and TypeScript checks arity at every call site, meaning any signature change (adding a required parameter) is a breaking change TypeScript will catch across your entire codebase — this is one of the genuinely valuable aspects of the error, since it prevents partially-updated refactors from shipping.
Optional parameters (?) and default parameter values solve different problems — an optional parameter can be undefined and the function must handle that explicitly, while a default value guarantees the parameter always has a defined value inside the function body even when omitted at the call site.
Optional parameters must come after required ones in a parameter list — TypeScript enforces this ordering because a required parameter after an optional one would create an ambiguous call site where you can't omit the optional one without also omitting the required one after it.
Overloaded function signatures can produce this error even when a call looks reasonable, if the specific combination of argument count and types doesn't match any of the declared overload signatures — in that case, the fix is checking each overload individually rather than assuming the general signature applies.
Fixing "Expected N Arguments, but Got M"
Fix 1: Update every call site to supply the now-required argument, which is usually the correct fix when a parameter was added deliberately:
createUser("Alex", "alex@example.com");
Fix 2: If the parameter should genuinely be optional, mark it with ? and handle the undefined case explicitly, rather than making a call site supply a placeholder value just to satisfy the type checker:
function createUser(name: string, email?: string) {
return { name, email: email ?? null, createdAt: new Date() };
}
Fix 3: If the parameter should have a sensible default rather than being truly optional, use a default parameter value, which both satisfies the type checker at existing call sites and guarantees a defined value inside the function:
function createUser(name: string, role: string = "member") {
return { name, role };
}
Should a New Required Parameter Be Optional Instead?
Make it optional (or give it a default) specifically when the function has a sensible behavior for callers that don't supply it — a genuinely optional feature flag or a value with a reasonable default fits this. Keep it required when omitting it would leave the function unable to do its job correctly — in that case, updating every call site (as TypeScript is forcing you to do) is the correct fix, not working around the requirement.
Preventing This Error in Production
Treat this error, when it appears after a refactor, as TypeScript correctly finding every call site that needs updating — resist the urge to make a newly-added parameter optional just to silence the error at old call sites if it's genuinely required for correct behavior. Use default parameter values for parameters that have a sensible fallback, since they avoid both the arity error and repetitive ?? defaultValue handling inside the function body.
If you hit this error broadly across a codebase after a signature change, that's the type checker doing exactly its job — work through each call site deliberately rather than loosening the signature just to make the error go away.