2

VS Code is an amazing text editor but I am facing some issues.

ISSUE

VS Code not showing IntelliSense for basic javascript functions like myVariable.toLowerCase();

enter image description here

Please let me know if there is any solution for this.

Thanks VS Code team for making development beautiful!

1 Answer 1

3

I'm on the VSCode team.

We cannot infer the types of JavaScript variables like categoryName in many cases, so we cannot know that toLowerCase is a valid method on categoryName. There are a few ways to fix this:

  • Use jsdoc to specify the argument type:

    /** * @param {string} categoryName */ function foo(categoryName){ // `string` member completions avalible here } 
  • Add a guard to the function:

    function foo(categoryName){ if (typeof categoryName !== 'string') return // `string` member completions available here } 
  • Use TypeScript or Flow types

    function foo(categoryName: string){ // `string` member completions available here } 

Hope that helps.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.