Skip to content

TypeScript snippets in VS #312

Closed
Closed

Description

Moving this over from CodePlex (23 votes, assigned to jonturner, http://typescript.codeplex.com/workitem/938):

I would really like to be able to use a TypeScript version of the JavaScript code snippets when writing TypeScript in Visual Studio.

Activity

  1. RyanCavanaugh commented on Jul 30, 2014

    @RyanCavanaugh
    Member

    What kind of snippets would you like to see?

  2. craigktreasure commented on Jul 31, 2014

    @craigktreasure
    Author

    I think all of the existing snippets for the JavaScript language would be a good start.
    JSDoc snippets and auto completion would be a huge win! I would love it if TypeScript code was as quick and easy to document as it is in C# today. For example, a /// is all it takes to generate the documentation scaffolding and then I just need to add descriptions.

    Also, TypeScript doesn't appear as a language in the Code Snippets Manager, so I can't add custom snippets (that i'm aware of anyways).

  3. Cotspheer commented on Aug 5, 2014

    @Cotspheer

    I miss the language too within the Code Snippets Manager. So for me it would be great if I just could add custom snippets. That's all what I need.

  4. knazeri commented on Aug 7, 2014

    @knazeri

    What kind of snippets would you like to see? Ryan Cavanaugh (@RyanCavanaugh)

    For starter I love /// to create a template of a documentation comment and fill in the parameters and other information. There are loads of different snippets that could make coding quicker and easier:

    • ctor
    • prop
    • switch
    • for
    • try
    • tryf

    And a shortcut to launch the Insert Snippet menu (ie. CTRL+K, X) would be nice.
    I also miss the magical smart tag (ctrl + .) to automatically import, implement interfaces, etc.. like everyday when I'm coding TypeScript in VS!

  5. mhegazy commented on Aug 7, 2014

    @mhegazy
    Contributor

    @KamyarNazeri /// comments template support should be an issue by itself. Just having snippets will not give you what you are looking for.

  6. knazeri commented on Aug 7, 2014

    @knazeri

    Mohamed Hegazy (@mhegazy) What kind of issue are we talking about?

  7. danquirk commented on Aug 7, 2014

    @danquirk
    Member

    He just means it's a separate feature from code snippets and should be tracked in a separate issue on the issue tracker.

  8. mhegazy commented on Aug 7, 2014

    @mhegazy
    Contributor

    yup. thanks Dan Quirk (@danquirk) for the clarification, we need two issues here :)

  9. frodegil commented on Aug 12, 2014

    @frodegil

    AngularJS code snippets for controllers, services, directives, etcetera would be really nice to have available in VS.

  10. NoelAbrahams commented on Aug 12, 2014

    @NoelAbrahams

    Frode Gilberg (@frodegil), AngularJS and code snippets for other frameworks will need to be handled by custom snippets. A custom snippet for JavaScript is defined as follows:

    <CodeSnippet Format="1.0.0" xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
        <Header>
            <Title>Closure</Title>
            <Author>Me</Author>
            <Shortcut>closure</Shortcut>
            <Description>Code snippet for a JavaScript closure</Description>
            <SnippetTypes>
                <SnippetType>Expansion</SnippetType>
                <SnippetType>SurroundsWith</SnippetType>
            </SnippetTypes>
        </Header>
        <Snippet>
            <Code Language="JavaScript">
                <![CDATA[(function () {
      $selected$
    })($end$);]]>
            </Code>
        </Snippet>
    </CodeSnippet>

    I believe this request is for TypeScript files to support the following:
    (a). Launch the "Insert Snippet" dialogue on Control+K, Control+X.
    (b). Provide a set of built-in snippets (for if, try etc)
    (c). Permit defining custom snippets as above.

  11. danquirk commented on Aug 12, 2014

    @danquirk
    Member

    Personally I don't think snippets should be in their own menu with a long, awkward key chord to invoke. There's no reason they can't be treated like any other completion result as many other languages/editors do.

  12. NoelAbrahams commented on Aug 17, 2014

    @NoelAbrahams

    Personally I don't think snippets should be in their own menu with a long, awkward key chord to invoke. There's no reason they can't be treated like any other completion result as many other languages/editors do.

    👍

  13. 56 remaining items

  14. added
    FixedA PR has been merged for this issue
    and removed
    CommittedThe team has roadmapped this issue
    SuggestionAn idea for TypeScript
    on Aug 12, 2016
  15. MaklaCof commented on Sep 8, 2016

    @MaklaCof

    I installed Microsoft Visual Studio Enterprise 15 Preview 4, but I don't see any options to insert snippet.
    Tried with:

    • Edit -> InstalliSense -> Insert snippet (doesn't exist)
    • Ctrl + k, Ctrl + x
    • Right click -> Insert Snippet

    In Tools -> Code Snippets Manager I don't see TypeScript in Language drop down.
    How can I insert snippet?

  16. paulvanbrenk commented on Sep 8, 2016

    @paulvanbrenk
    Contributor

    Makla (@MaklaCof) Snippets for TypeScript is not available in Preview 4, but will be in the next release.

  17. MaklaCof commented on Sep 9, 2016

    @MaklaCof

    Then someone should fix Milestone to avoid confusion.

  18. added a commit that references this issue on Sep 27, 2016
  19. lorenlew commented on Dec 21, 2016

    @lorenlew

    Paul van Brenk (@paulvanbrenk), as you mentioned "Snippets will be part of VS "15" post Preview 4."
    what about VS 2015?

  20. paulvanbrenk commented on Dec 21, 2016

    @paulvanbrenk
    Contributor

    Mikhail Koltasheu (@lorenlew) unfortunately we won't be back porting them VS 2015.

  21. locked and limited conversation to collaborators on Jun 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

FixedA PR has been merged for this issueVisual StudioIntegration with Visual Studio

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions