jos@devoon.nl wrote:
We also typecast explicitly some variables as 2 types like this @type{tupe1|type2} but it gives nevertheless a warning as if this kind of type is something different i.e. @type{type1|type2} equals not @type{type1} or vice versa.
what are you exactly doing?
it is correct that a type that is of type1|type2 doesn't fit into a type1 only
so:
- Code: Select all
/**
* @param {type1} a
*/
function test(a) {}
/** @type {type1|type2}
var x = something;
test(a)
that test function will result in a warning.. because x can also be of type2 and the test function doesn't accept that.
This is also just bad code.. You should never have variable declarations that are typed like that
a union type should only be used for params.. To reflect overloaded method. But variables inside methods and so on should always be just of one type.