javascriptvisual-studio-codecodelens

Using CodeLens for JavaScript in VSCode


I'm trying to get CodeLens working for a JavaScript project in VSCode. I've seen multiple sources indicate that this should work, but nothing with clear instructions on how to enable it besides the basic settings.

I have the following files in my workspace:

test.js

function test ( a, b ) {
    return a + b;
}

test( 1, 2 );

jsconfig.json

{
    "compilerOptions": {
        "target": "ES5",
        "checkJs": true
    },
    "include": [
        "*"
    ]
}

And in my user settings I have the following:

"javascript.referencesCodeLens.enabled": true

(editor.codeLens is enabled by default.)

I've toggled and saved my preferences several times. I've restarted VSCode a few times as well. Still, I don't see any CodeLens information within my JavaScript.

Did I miss something? Am I doing something wrong? Do I even need the jsconfig.json file to enable this?

VSCode 1.17.0.


Solution

  • As of VS Code 1.17, we only show JS/TS references code lenses on classes, methods, and exports.

    This issue tracks showing them in more locations, including on functions as in your example.