RepoPilot

What is the type signature of the main exported function?

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

Question

What is the type signature of the main exported function?

RepoPilot

The main exported function getPort has the following type signature [index.d.ts:L66]:

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

This function takes an optional Options object and returns a Promise that resolves to a port number.

The Options type is defined as [index.d.ts:L3-L65], which includes:

  • port?: number | Iterable<number> — A preferred port or iterable of preferred ports
  • exclude?: Iterable<number> — Ports to exclude from consideration
  • reserve?: boolean — Whether to reserve the port for the lifetime of the process (default: false)
  • host?: string — The host on which to check port availability
  • Plus additional properties from Node's ListenOptions (minus the port field)

FOLLOW_UPS:

  • How does the function handle preferred ports?
  • What happens when no ports are available?
  • How does the reserve option work internally?

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.