TS2532

error TS2532: Object is possibly ‘undefined’.

Bad Code ❌

1
2
3
if (queueObject) {
queueObject.retry -= 1;
}

Fixed Code ✔️

1
2
3
if (queueObject) {
queueObject.retry! -= 1;
}

Bad Code ❌

1
const ownerIds: string[] = process.env.WIRE_OWNER_IDS.split(',')

Fixed Code ✔️

1
const ownerIds: string[] = String(process.env.WIRE_OWNER_IDS).split(',')