The code is like this:
class MyClass {
getValue() {
// some code here...
}
}
const IS_ENABLED = process.env.IS_ENABLED || false;
const myClass = IS_ENABLED ? new MyClass() : null;
function getValue() {
if (!IS_ENABLED) return false;
return myClass.getValue();
}
Now at this point, TypeScript is giving error (for myClass.getValue()):
Object is possibly 'null'.
But, since I've checked the condition, I'm sure it's not null.
Is there any way for TypeScript to handle it?