30

I'm using VSCode, Exist, a way to implement the methods that are within an interface in typescript using some shortcut keys or set for it.

I searched on the website of Microsoft, and the web, but I have not found anything.

3
  • 3
    Can you please reconsider marking the correct answer?
    – knaos
    Jun 29, 2017 at 13:25
  • 2
    Could you make @knaos 's answer the one marked as answered? Mine no longer is true.
    – toskv
    Sep 17, 2018 at 6:35
  • Last seen back in '17
    – spencer741
    Feb 26, 2021 at 16:13

5 Answers 5

48

UPDATE: VS Code now supports this functionality out of the box. Just add the interface, the compiler will highlight the controller with red, right click on the light bulb on the left and click implement interface. Enjoy!

Interface implementing

8
  • 3
    Is there a shortcut for that?
    – sowdri
    Jun 7, 2017 at 7:15
  • 19
    @sowdri There is a shortcut for it, when your cursor is on the red underlined work press ctrl+. Nov 7, 2017 at 16:24
  • It's worth noting that the code action won't appear if the interface you want to implement has only nullable/non-required members. stackoverflow.com/a/49430045/4028303 Mar 22, 2018 at 13:37
  • 1
    @JimShowalter It still works for me in the latest VSCode version.
    – Oleksiy
    Dec 24, 2018 at 0:49
  • 1
    cmd+. on macos
    – vigilancer
    Feb 19, 2019 at 13:54
12

Update: The shortcut in VsCode for accessing this quick action is the usual one: Ctrl + . (period).

The built-in functionality of VsCode implementing an interface was first resolved for me by upgrading and using the Visual Studio Code -Insiders version instead.

See: VsCode Insiders for downloading this edition of VsCode.

Note that using the insiders editions might impact other aspects of your apps, as the versions are more beta than the public VsCode editions.

Implement Typescript interface built-in option in VsCode

2
  • Although your post is very clear and well made, it is not an answer to this question... The question was about what the shortcut for that action is Jul 1, 2019 at 10:54
  • 3
    @UTF_or_Death I updated my answer regarding the shortcut for triggering the quick action in VsCode. Jul 1, 2019 at 19:55
9

It will be "ctrl+." for visual studio code linux version or click on the light bulb icon(enter image description here).

1
  • So useful, literally spent 20mins researching, getting frustrated, nearly closed my project to use it visual studio. Thanks! :D
    – Jones
    May 26, 2021 at 8:46
3

There isn't such a shortcut by default.

You can search for an extension on the marketplace. I didn't find any.

2
  • 8
    can you mark @knoas 's answer as the correct one? Mine is no longer valid.
    – toskv
    Feb 25, 2019 at 13:34
  • on Mac just press cmd and . together. Feb 5, 2022 at 14:16
3

If you are using mac, the shortcut is CMD + .

Not the answer you're looking for? Browse other questions tagged or ask your own question.