How to fix Expected at least 1 argument, but got 0 in TypeScript

TypeScriptBEGINNERMEDIUMUpdated Dec 8, 2025· 161 views

This TypeScript error occurs when you call a function without providing any arguments, but the function requires at least one parameter. TypeScript enforces that all required parameters must be provided when calling a function to prevent runtime errors.

Quick fix

Fixes TS2554

// Function definition
function greet(name: string) {
  return `Hello, ${name}!`;
}

// WRONG: Calling without arguments
const message = greet(); // Error: Expected 1 argument, but got 0

// CORRECT: Provide the required argument
const message = greet("Alice"); // OK
  1. Check the function signature to see what parameters are required
  2. Provide the required argument(s) when calling the function
  3. Make parameters optional if they're not always required
  4. Use default parameter values for common defaults
typescript — error
// Function definition
function greet(name: string) {
return `Hello, ${name}!`;
}
// WRONG: Calling without arguments
const message = greet(); // Error: Expected 1 argument, but got 0
// CORRECT: Provide the required argument
const message = greet("Alice"); // OK
Expected at least 1 argument, but got 0

What this error means

TypeScript's type system ensures that functions are called with the correct number and types of arguments. When you define a function with required parameters (without the `?` optional marker or default values), TypeScript enforces that you must provide those arguments when calling the function. The error "Expected at least 1 argument, but got 0" (TS2554) means you're calling a function that requires one or more parameters, but you're invoking it with an empty argument list: `myFunction()`. This is a key difference from JavaScript, where functions can be called with fewer arguments than defined—missing parameters simply become `undefined`. TypeScript prevents this by default to catch potential bugs at compile time, ensuring that functions receive the data they expect to operate correctly.

Typical symptoms

  • Red squiggly line appears under the function call in your IDE
  • TypeScript compilation fails with error TS2554
  • Error message shows 'Expected at least 1 argument, but got 0' or similar with different numbers
  • The function has one or more parameters but is called with empty parentheses
  • Code works when you add arguments, but fails when you remove them
  • The error appears even though the parameter seems optional in your mind

Common causes

  1. Function has required parameters but is called without any arguments
  2. You forgot to pass the required argument when calling the function
  3. Parameter was meant to be optional but wasn't marked with '?' or given a default value
  4. Function signature was changed to require arguments, breaking existing calls
  5. Copy-paste error where you copied a function call but removed the arguments
  6. Attempting to call a function before understanding its parameter requirements
  7. Function overload selected by TypeScript requires arguments, not the no-arg version

How to fix "Expected at least 1 argument, but got 0"

1Check the function signature to see what parameters are required

First, inspect the function definition to understand what arguments it expects:

typescript
// Function definition
function greet(name: string) {
  return `Hello, ${name}!`;
}

// WRONG: Calling without arguments
const message = greet(); // Error: Expected 1 argument, but got 0

// CORRECT: Provide the required argument
const message = greet("Alice"); // OK

In VS Code, hover over the function name to see its signature and required parameters. The signature will show you exactly what the function expects.

2Provide the required argument(s) when calling the function

The simplest fix is to pass the required arguments to the function:

typescript
// Function with one required parameter
function calculateDiscount(price: number) {
  return price * 0.1;
}

// BEFORE: Error
const discount = calculateDiscount(); // Expected 1 argument, but got 0

// AFTER: Provide the price
const discount = calculateDiscount(100); // OK - returns 10

// Function with multiple required parameters
function createUser(name: string, email: string) {
  return { name, email };
}

// BEFORE: Error
const user = createUser(); // Expected 2 arguments, but got 0

// AFTER: Provide both arguments
const user = createUser("Alice", "alice@example.com"); // OK
3Make parameters optional if they're not always required

If the parameter should be optional, mark it with ? after the parameter name:

typescript
// BEFORE: Parameter is required
function greet(name: string) {
  return `Hello, ${name}!`;
}
greet(); // Error: Expected 1 argument, but got 0

// AFTER: Make parameter optional
function greet(name?: string) {
  return `Hello, ${name || "Guest"}!`;
}
greet(); // OK - name is undefined, defaults to "Guest"
greet("Alice"); // OK - name is "Alice"

Important: Optional parameters must come after required parameters:

typescript
// WRONG: Optional parameter before required
function createUser(email?: string, name: string) {} // Error

// CORRECT: Required parameters first, optional last
function createUser(name: string, email?: string) {} // OK
4Use default parameter values for common defaults

Default parameters are automatically optional and provide a fallback value:

typescript
// BEFORE: Required parameter
function createConnection(timeout: number) {
  // ...
}
createConnection(); // Error: Expected 1 argument, but got 0

// AFTER: Use default value
function createConnection(timeout: number = 5000) {
  // ...
}
createConnection(); // OK - timeout is 5000
createConnection(10000); // OK - timeout is 10000

Default values can be complex expressions:

typescript
function fetchData(url: string = "/api/default") {
  // ...
}

function createId(prefix: string = `id-${Date.now()}`) {
  // ...
}

Note: Do NOT use both ? and a default value—the default value already makes it optional:

typescript
// WRONG: Redundant ?
function greet(name?: string = "Guest") {} // Error

// CORRECT: Default value is enough
function greet(name: string = "Guest") {} // OK
5Use rest parameters if the number of arguments is variable

If your function should accept zero or more arguments, use rest parameters:

typescript
// BEFORE: Fixed parameter count
function sum(a: number, b: number) {
  return a + b;
}
sum(); // Error: Expected 2 arguments, but got 0
sum(1); // Error: Expected 2 arguments, but got 1

// AFTER: Use rest parameters
function sum(...numbers: number[]) {
  return numbers.reduce((total, n) => total + n, 0);
}
sum(); // OK - returns 0
sum(1); // OK - returns 1
sum(1, 2, 3, 4); // OK - returns 10

You can combine required parameters with rest parameters:

typescript
// First message is required, additional messages are optional
function log(firstMessage: string, ...additionalMessages: string[]) {
  console.log(firstMessage);
  additionalMessages.forEach(msg => console.log("  -", msg));
}

log("Hello"); // OK
log("Hello", "World", "!"); // OK
log(); // Error: Expected at least 1 argument, but got 0
6Check for function overloads selecting the wrong signature

If a function has multiple signatures (overloads), TypeScript might be selecting one that requires arguments:

typescript
// Function with overloads
function processData(data: string): string;
function processData(): void;
function processData(data?: string): string | void {
  if (data === undefined) {
    console.log("No data provided");
    return;
  }
  return data.toUpperCase();
}

// This works fine
processData(); // OK - matches second overload
processData("hello"); // OK - matches first overload

If you see the error despite having a no-argument overload, the overload order might be wrong. Overloads are checked from top to bottom, and the implementation signature must be compatible with all overloads.

For library functions, check the type definitions to see which overloads are available:

typescript
// Example: Array.from has overloads
Array.from(); // Error: Expected at least 1 argument
Array.from([1, 2, 3]); // OK
Array.from({ length: 3 }, (_, i) => i); // OK - uses different overload

Advanced notes

### Strict Function Types

TypeScript's strictFunctionTypes compiler option affects how function parameters are checked. With strict mode enabled (recommended), TypeScript is more careful about function argument requirements:

json
// tsconfig.json
{
  "compilerOptions": {
    "strict": true, // Enables strictFunctionTypes
    "strictFunctionTypes": true
  }
}

### Callback Functions

When passing callbacks, ensure they match the expected signature:

typescript
// Event listener expects a callback with an event parameter
button.addEventListener("click", handleClick);

// WRONG: Handler doesn't accept the event
function handleClick() { // Error when strict checking enabled
  console.log("Clicked");
}

// CORRECT: Accept the event parameter (even if unused)
function handleClick(event: MouseEvent) {
  console.log("Clicked");
}

// Or mark it optional if the framework allows
function handleClick(event?: MouseEvent) {
  console.log("Clicked");
}

### Array Methods and Required Callbacks

Some array methods require callbacks with specific signatures:

typescript
const numbers = [1, 2, 3];

// Array.map requires a callback with at least one parameter
numbers.map(); // Error: Expected 1 argument, but got 0

// Even if you ignore the parameter, you must declare it
numbers.map((item) => item * 2); // OK
numbers.map(() => 42); // OK - parameter can be omitted in arrow functions

### Constructor Functions

The same rules apply to class constructors:

typescript
class User {
  constructor(name: string, email: string) {
    // ...
  }
}

const user = new User(); // Error: Expected 2 arguments, but got 0
const user = new User("Alice", "alice@example.com"); // OK

// Make constructor parameters optional if needed
class User {
  constructor(name: string = "Anonymous", email?: string) {
    // ...
  }
}

const user = new User(); // OK

### Partial Application and Currying

If you need to call a function in stages, consider using currying:

typescript
// Instead of requiring all arguments at once
function createUrl(protocol: string, domain: string, path: string) {
  return `${protocol}://${domain}${path}`;
}

// Use currying to allow partial application
function createUrl(protocol: string) {
  return (domain: string) => {
    return (path: string) => {
      return `${protocol}://${domain}${path}`;
    };
  };
}

const https = createUrl("https"); // OK
const site = https("example.com"); // OK
const url = site("/api/users"); // OK

### Void vs Undefined

Functions that don't require arguments should explicitly define no parameters:

typescript
// UNCLEAR: Has a parameter that looks required
function initialize(config: undefined) {} // Confusing

// BETTER: No parameters at all
function initialize() {} // Clear

// Or use void in the signature
type InitFn = () => void;
const initialize: InitFn = () => {
  // ...
};

Frequently asked questions

What does "TS2554" mean?
TypeScript's type system ensures that functions are called with the correct number and types of arguments. When you define a function with required parameters (without the ? optional marker or default values), TypeScript enforces that you must provide those arguments when calling the function.
How do I fix "TS2554"?
This TypeScript error occurs when you call a function without providing any arguments, but the function requires at least one parameter. TypeScript enforces that all required parameters must be provided when calling a function to prevent runtime errors.
What causes "TS2554"?
Function has required parameters but is called without any arguments You forgot to pass the required argument when calling the function Parameter was meant to be optional but wasn't marked with '?' or given a default value
Is the "TS2554" error serious?
It is a medium-severity error — more of a blocker than a risk. The steps above resolve it.

Official resources & further reading