Closed
Description
Hi,
I have an issue about the strictNullChecks
, indeed I am using it right now and it says "Object is possibly 'undefined'." on an object cannot be undefined.
TypeScript Version: 2.5.3
Code
Failling code
// Retrieve circle with identifier
const circle: Circle | undefined = await this.circleDao.findById(command.getId());
// Check if localAuthority is found in database
Utils.checkArgument(circle !== undefined, "Circle with id '" + command.getId() + "' cannot be found");
// Compiler fail on this line with message "Object is possibly 'undefined'."
circle.setDefaultCircle(command.isDefaultCircle());
Utils.ts method
public static checkArgument(expression: boolean, message?: string) {
if (!expression) {
throw new IllegalArgumentError(message);
}
}
Expected behavior:
When I check if an object is undefined in an external method the compiler can see it and don't throw error : "Object is possibly 'undefined'."
Actual behavior:
When I check if an object is undefined in an external method the compiler throw error : "Object is possibly 'undefined'."