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) {}
}
};
Please sign in to leave a comment.
Please vote for https://youtrack.jetbrains.com/issue/WEB-40879 and https://youtrack.jetbrains.com/issue/WEB-38020 to be notified on any progress with these tickets
Thanks.