TS1109

error TS1109: Expression expected.

Bad Code ❌

1
2
const name = ['Benny', '']
const lastName = name[1] || throw new Error('Missing last name');

Fixed Code ✔️

1
2
3
4
5
const name = ['Benny', ''];
const lastName = name[1];
if (!lastName) {
throw new Error('Missing last name');
}