Return expression type is not assignable to type.

Ever since I updated to Webstorm EAP 7, build WS-13.48, objects in nodejs that are marked as a specific type show this error.

Steps to recreate:

/** @type {{t:Number, l:Number, b:Number, r:Number}} */
var Box = null;

/** @type {Box} */
var a = {t:1, b:5,  l:4, r:6};

You can see the error imediately.

2 comments

Hi Alexandru,
Could you please point where such declaration is used in nodejs? Normally, you should use @typedef instead of @type in this case on the first line. (see https://developers.google.com/closure/compiler/docs/js-for-compiler)

Regards,
Konstantin

0

I have use @type untill now and it worked :| could it be I was using it wrong and the warning was never implemented or was broken?
I will try to see if @typedef fixes things.

Thank you.

Update:
I have tested and indeed @typedef works as intended. Thank you for your assistance.

0

Please sign in to leave a comment.