JavaScript: Invalid not assignable warning

Inside my JavaScript code, IntelliJ IDEA 12 is reporting the warning, "        Binary operation argument type String is not assignable to type Current" for the following if statement:

if ( currentPageId == "workOrderListPage" )

The if statement above is not trying to assign anything and there is no type Current.  And the if statement above is valid so I think this warning is invalid.

1.  How would I change the if statement above to eliminate the warning
2.  Which inspection do I turn off to disable this warning.

I am using IDEA 12.0.3 Build 123.155.

4 comments

Tried to reproduce the problem with the simple js file below but haven't succeeded:

function test(currentPageId) {
    if (currentPageId == "workOrderListPage") {
        alert("test")
    }
}



Also checked the codebase and it's not an inspection but core javascript highlighting, i.e. it's not possible to turn it off selectively.

Please provide an exact sample file where you get the problem.

Denis
0

Here is an example that shows this.

/**
* Return the current page ID
* @returns Current page ID which can serve as a key into Pages
*/
function getCurrentPageId() {
    return "currentId";
}

/**
* Save handler for the terminate clocking dialog
*/
function terminateClockingDialogSaveHandler() {
    var currentPageId = getCurrentPageId();
    if ( currentPageId == "workOrderListPage" ) {
        alert( currentPageId );
    }
}



Strictly speaking, the warning for the if statement could be considered valid because the @returns line inside the JSDoc for getCurrentPageId() defines Current as the type.
However, I think putting the warning on the if statement is confusing because no assignment is being done here.
0

Ok, thanks.

I confirm that the problem is reproduced at local environment.

Denis

0

Please sign in to leave a comment.