When the validate function returns an object where a key, e.g. OPT
, is undefined
, assignVariablesToProcess
will assign undefined
to process.env.OPT
which will stringify it (see https://nodejs.org/api/process.html#processenv). This results in ConfigService.get
returning process.env.OPT
which now has the value 'undefined'
.
yarn run start
and observe the log.
The second generic parameter (WasValidated
) changes the return value of ConfigService.get
. If true
, it removes undefined
from the return type. If false
, it adds undefined
. The problem here is that a value could be both validated and undefined
.
Observe the TypeScript return type of optValue
in main.ts
.