Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

interface properties are duplicating in vscode

I have this code:

interface Config {
  initialState?: any
  openIndicator?: any
  closeIndicator?: any
  open?: () => void
  close?: () => void
  manualOpen?: () => void
  manualClose?: () => void
}

function ABC(config: Config) {

}

when I start writing:

ABC({
  // my pointer is here
})

I see these suggestions:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

enter image description here

Why are they duplicating? close is there two times, open is there two times.

Why? Is this something not standard in my code? Or is it intentional? What’s the benefit of duplicating the interface properties in the autocompletion of vs-code?

>Solution :

Notice that this happens only for the functions. This is because one of those options simply autocompletes the key name for you while the other one (the one with parenthesis) also adds a function body.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading