Hello,
I get this error: Property cannot be assigned on possibly undefined value. My code looks like this:
const clients = new Map();
if (
clients.has('clientAddress') && // <- This doesn't helps
typeof clients.get('clientAddress') !== 'undefined' && // <- This doesn't helps too
clients.get('clientAddress').hasOwnProperty('lastResponse') // <- call of method `hasOwnProperty` (Method cannot be called on possibly undefined value)
)
clients.get('clientAddress').lastResponse = 'response'; // <- property `lastResponse` (Property cannot be assigned on possibly undefined value)
Flow: latest
Node.js: latest
You need to assign clients.get('clientAddress') to variable before checking
@vkurchatkin Thanks!
Most helpful comment
You need to assign
clients.get('clientAddress')to variable before checking