Why do i see 'object is possibly 'null' or 'undefined' in typescript?

This error arises due to TypeScript's strict null checks. TypeScript is warning that an object might be null or undefined and can cause a runtime error.

Example:

  let exampleObj: { value?: string } = {};
  console.log(exampleObj.value.toUpperCase());
  
Solution:

  if (exampleObj.value) {
      console.log(exampleObj.value.toUpperCase());
  }
  

Beginner's Guide to TypeScript