RepoPilot

What is the type signature of the main exported function?

About sindresorhus/get-port · 2 messages · last activity 7/6/2026

Question

What is the type signature of the main exported function?

RepoPilot

The main exported function getPort has the following type signature:

export default function getPort(options?: Options): Promise<number>;

This is defined in [index.d.ts:L66].

The function accepts an optional Options object and returns a Promise<number> — the promised port number. The Options type is defined in [index.d.ts:L3-L65] and includes properties like:

  • port: A preferred port or iterable of preferred ports
  • exclude: Ports to exclude from consideration
  • reserve: Whether to lock the port for the process lifetime
  • host: The specific host to check availability on

FOLLOW_UPS:

  • What does the portNumbers() helper function do?
  • How does the reserve option work internally?
  • What error handling occurs when no ports are available?

Want to ask your own question?

Open chat for sindresorhus/get-port

Public Q&A. Generated by RepoPilot from the actual source of sindresorhus/get-port. AI answers can be incomplete or stale — verify before relying on them.