Page 1 of 1

JSDoc Disabled in 'If' Statement

PostPosted: Fri Jun 22, 2012 8:13 pm
by kwpsd
Version: 6.0.6 - build 1232

When testing code, I disable certain sections by temporarily including them in an 'if' statement, for example:

Code: Select all
    if ( true )
    {
        /** @type {JSFoundset<db:/databaseName/tableName>} */
       
        var fs = databaseManager.getFoundSet( 'databaseName', 'tableName' )
       
        fs.fieldName1 = data1
    }


Within the 'if' statement, if I add another line of code, for example:

Code: Select all
fs.fieldName2 = data2


the JSDoc code completion works as I type. However, if I change 'true' to 'false', then code completion is disabled within the 'if' statement.

What is the purpose of disabling code completion based on a conditional statement in my code? This strikes me as odd behavior, but, perhaps there is a plausable explanation?

Re: JSDoc Disabled in 'If' Statement

PostPosted: Sat Jun 23, 2012 4:38 pm
by omar
This has nothing to do with JSDoc but is a result of the way syntax checking is performed. The compiler recognizes the 'dead code' situation and handles accordingly. Not only the intellisense is disabled but error and warning checking as well. The following will compile without any errors or warnings.

Code: Select all
function test() {
    if ( false )
    {
       var x = bigFatError;   
    }
}


Maybe a dead code warning would be appropriate in this situation...