possible-null assignment to non-null, notes

This commit is contained in:
dcode
2019-04-09 06:57:28 +02:00
parent cd79376101
commit eb6c4c09ee
5 changed files with 84 additions and 53 deletions

View File

@ -99,14 +99,23 @@ export function testLogicalAndMulti(a: Ref | null, b: Ref | null): void {
if (a && b) {
if (isNullable(a)) ERROR("should be non-nullable");
if (isNullable(b)) ERROR("should be non-nullable");
} else {
if (!isNullable(a)) ERROR("should be nullable");
if (!isNullable(b)) ERROR("should be nullable");
}
}
export function testLogicalOrMulti(a: Ref | null, b: Ref | null): void {
if (!a || !b) {
// something
if (!isNullable(a)) ERROR("should be nullable");
if (!isNullable(b)) ERROR("should be nullable");
} else {
if (isNullable(a)) ERROR("should be non-nullable");
if (isNullable(b)) ERROR("should be non-nullable");
}
}
export function testAssign(a: Ref | null, b: Ref): void {
a = b;
if (isNullable(a)) ERROR("should be non-nullable");
}