TSConfig

strictNullChecks

When strictNullChecks is false , null and undefined are effectively ignored by the language. This can lead to unexpected errors at runtime.

When strictNullChecks is true , null and undefined have their own distinct types and you’ll get a type error if you try to use them where a concrete value is expected.

For example with this TypeScript code, users.find has no guarantee that it will actually find a user, but you can write code as though it will:

ts
declare const loggedInUsername: string;
 
const users = [
{ name: "Oby", age: 12 },
{ name: "Heera", age: 32 },
];
 
const loggedInUser = users.find((u) => u.name === loggedInUsername);
console.log(loggedInUser.age);
Try