1

Trying to use the Microsoft VS code to develop node.js app. I'm starting with deciding if it worth the effort of learning this new IDE (new for me). so for now i am not asking about node.js completion rather my own objects.

I read about adding code completion for different packages, but my problem is much more basic.

I can't get code completion for my own JS objects. Lets say i have this simple object:

function User() {
    this.name = '';
}

var me = new User();
me. ????

when trying to get to the name property of User after instantiating it there is no code completion for the object properties.

It is something i am doing wrong or is it a basic problem?

to be clear. i am getting code completion for the node.js classes built in JS objects.

It has some really great things built in it but i can't find a solution for this basic problem.

10x

1
  • VSCode only seems to be able to autofill keywords that are declared as part of the code's syntax, rather than its runtime state. To try to explain, User.state exists as a result of this.name = '', a run-time action. By contrast, me exists syntactically because of var me and could not "conditionally exist" or have possibly been removed at some other point. You CAN get around this by creating TypeScript definition files for commonly-used code (You do not necessarily need to work 100% in TypeScript) Commented Mar 3, 2016 at 16:36

1 Answer 1

2

It seems that VSCode does not detect this pattern. If you would use a ES6 class:

class User {
    constructor() {
       this.name = '';
    }
}
var me = new User();
me. // now proposes name
Sign up to request clarification or add additional context in comments.

1 Comment

I posted an an issue to vscode/typescript

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.