Skip to content

PortNumber

PortNumber = number & object

Defined in: packages/net-address/src/port/port.ts:15

A validated TCP or UDP port number.

The tag is declared, never constructed, so the type costs nothing at runtime. It exists so a function taking a port cannot be handed an arbitrary number that nobody range-checked: the only ways in are toPortNumber, parsePort and the isPortNumber guard.

readonly [portNumberTag]: true