Return value of type undefined is required

return_error.png

See the error squiggle under the return; the error generated is "Return value of type undefined is required". It seems to be caused by the @return in the comment above the function. If I completely remove the line " * @return undefined " the error goes away.
If I put it back it comes back, but not always right away!

So, my question is this. Why does the commented line above cause the return statement in this Javascript function ( pulled from the jCarousel source ) to show as an error in phpStorm?

O.

0
6 comments

Change it to @return void

0

in javascript isn't void and undefined the same thing? So why does void work and not undefined?

void 0  === undefined   <-- evaluates to true after all.

But more importantly, how does the comment affect the return statement in the code? That's what has me confused.

O.

0

Not sure about the void === undefined aspect, but the comment is saying that the return type is incorrect and marking it for you.

0

fair enough!

Now the big question.

Why is the comment marking this?  Does it have something to do with the '@' before the return? Is this phpDoc stuff at work? I've tried doing a bit of research, but I'm coming up fairly blank as to the mechanics behind this comment interaction stuff and how it's supposed to be employed!

O.

0

Ah, yes. Sorry, I thought just assumed you were familiar with PHPStorm and how it uses the PHPDoc syntax to specify parameter types (in PHP) and return types (in PHP or JS.)

0

Not a problem!

I'm easily confused! ;)

I've only been programming regularly in php and javascript since May 2nd! I have a lot of catchup to do.

Coming to this from .NET so it's been interesting.

Loving phpStorm and it's focused environment over eclipse or Netbeans (the other two IDE's I've tried for php development) a lot!

So much to learn!

O.

0

Please sign in to leave a comment.