TypeScript snippets in VS
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.
What kind of snippets would you like to see?
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).
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.
What kind of snippets would you like to see? @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!
@KamyarNazeri /// comments template support should be an issue by itself. Just having snippets will not give you what you are looking for.
@mhegazy What kind of issue are we talking about?
He just means it's a separate feature from code snippets and should be tracked in a separate issue on the issue tracker.
yup. thanks @danquirk for the clarification, we need two issues here :)
AngularJS code snippets for controllers, services, directives, etcetera would be really nice to have available in VS.
@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.
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.
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.
:+1:
I second @NightkingCH ! If TypeScript were visible as a language in Snippet Manager we could create our own snippets and use them. Currently I if make TS snippets as JavaScript they are not usable in TS files :-(
Totally agree with @NightkingCH .
Here's a dark way to make JS snippets work in TS... But certainly we won't use it in practice, just for fun.
- Create a JS file and open it.
- Rename it to .ts...
- LOL...
And it's a shame that there is still no snippet support in TS 1.3 for VS 2013.
Just out of curiosity, are snippets going to make into VS2015 final release? Or the preview release is pretty much everything we will see the final release?
Just ran into this issue today. :+1: please!
Add TS language to Code Snippets Manager, please!
12 more votes for TS Code Snippets!!!! Custom Snippets at a minimum, and maybe useful snippets out of the box.
I am repping my colleagues :)
An auto curry interface generator would be nice too:
http://stackoverflow.com/questions/28566969/create-programmable-snippet-for-visual-studio-with-node-js-code