Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

189
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda