RepoPilot

What is the type signature of the main exported function?

About sindresorhus/get-port · 2 messages · last activity 7/13/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>;

It accepts an optional Options object and returns a Promise that resolves to a number (the available port).

The Options type [index.d.ts:L3-L65] is an object that can include:

  • port: a preferred port number or iterable of port numbers
  • exclude: an iterable of port numbers to exclude from consideration
  • reserve: a boolean (default false) to lock the port for the process lifetime
  • host: a string specifying which host to check availability on
  • Plus additional options inherited from Node's ListenOptions (except port)

FOLLOW_UPS:

  • What does the reserve option actually do?
  • How does getPort handle multiple preferred ports?
  • What errors can getPort throw?

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.