Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

185
Views
VS Code Intellisense for Classes/Objects

I am using JS for my development. Is there any way to have intellisense (auto-suggest the method names / members) if I have an object that takes in another object in its constructor?

Example:

// sampleobj.js
import Consumer from './consumer.js'

class Sample {
  print () {
    console.log('hello this is inside sample')
  }
}
const sample = new Sample()
const consumer = new Consumer(sample)
consumer.consumerPrinter()

As you can see above, intellisense works fine, it suggests the Consumer object's methods.

enter image description here

My problem is the other way around. Since Consumer takes in Sample object in its constructor, how can I make VS Code suggest Sample's methods inside Consumer class?

class Consumer {
  constructor(sample) {
    this.sample = sample
  }

  consumerPrinter () {
    console.log('this prints inside consumer')
  }

  accessSampleMethod () {
    // this.sample. -- how to have intellisense here to suggest Sample's methods?
  }
}

export default Consumer

As you can see on line 11, this.sample doesn't have any autosuggestions - how to have intellisense here?

Or is there an easy way to let the Consumer class know that sample argument in the constructor is of type Sample class?

enter image description here

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!