Search code examples
typescriptvisual-studio-code

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:

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.