I have two warning and i don't understand why ...

Why i get these weak warnings?

let test = function()
{
/** @type {string|null} */
this.One = null; // Assigned expression type null is not assignable to type string.
/** @type {string|null} */
let Two = null; // But this works without warning and is the same.

// Why the first object is no checking for the 'null' if i defined in type?
// If i disable the 'Type mismatch' will stop the 'Two' for validating correctly if i put a number.


this.Call = () =>
{
// Condition is always false since types 'string' and 'null' have no overlap
// I don't understand this message why 'Is always false'. If is 'null === null' is true.
// Why this message is shows from the first place?

// In 'Inspection Results' its say: Comparison of expressions having incompatible types. What?
// That is the point of '===' to checking if the variables is equal and the same type.
// I already say on '@type' can be 'null', Why is incompatible types?

if (Two === null) {}
}
};

If i have like this:


let test2 = function()
{
/** @type {String} */
this.One = null; // No warnings.
/** @type {String} */
let Two = null; // No warnings.

this.Call = () =>
{
// No warnings.

if (Two === null) {}
}
};
0
2 comments
Avatar
Permanently deleted user

Thanks.

0

Please sign in to leave a comment.