Skip to content

Instantly share code, notes, and snippets.

@MarkRobertJohnson
Created September 19, 2017 23:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MarkRobertJohnson/5301762043163692f364473fe17f167b to your computer and use it in GitHub Desktop.
Save MarkRobertJohnson/5301762043163692f364473fe17f167b to your computer and use it in GitHub Desktop.
Visual Studio snippet for TypeScript property setter and getter
<CodeSnippet Format="1.1.0" xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<Header>
<Title>prop</Title>
<Author>Mark R. Johnson</Author>
<Shortcut>prop</Shortcut>
<Description>Code snippet for a property</Description>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>type</ID>
<Default>string</Default>
</Literal>
<Literal>
<ID>property</ID>
<Default>fullName</Default>
</Literal>
<Literal>
<ID>field</ID>
<Default>property</Default>
</Literal>
</Declarations>
<Code Language="TypeScript">
<![CDATA[
private _$field$: $type$;
get $property$(): $type$ {
return this._$field$;
}
set $property$(value: $type$) {
this._$field$ = value;
}
]]></Code>
</Snippet>
</CodeSnippet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment