const port = process.env.PORT;
string | undefinedThe type is string | undefined. Node's types declare every process.env value this way, for two reasons:
• Any variable may be unset, so it can be undefined.
• Environment values are always strings.
It is never number. A common pattern is to parse process.env once at startup with a schema, for example z.coerce.number(). Then you export a typed config object for the rest of the app.
Read more