diff --git a/snippets/typescript.snippets b/snippets/typescript.snippets new file mode 100644 index 00000000..b22e9c02 --- /dev/null +++ b/snippets/typescript.snippets @@ -0,0 +1,134 @@ +## Typescript snippets + +# Module +snippet mod + module ${1:module_name} { + export ${2:first_export}; + ${3:// ...} + } + +# Interface +snippet itf + interface ${1:interface_name} { + ${2:first_property}: ${3:first_type}; + ${4:// ...} + } + +# Class +snippet cl + class ${1:class_name} { + constructor(${2:constructor_arguments}) { + ${3:// constructor_body} + } + ${4:// body} + } + +# Class extends +snippet ce + class ${1:class_name} extends ${2:super_class} { + constructor(${3:constructor_arguments}) { + ${4:// constructor_body} + } + ${5:// body} + } + +# Class implements +snippet ci + class ${1:class_name} implements ${2:interface} { + constructor(${3:constructor_arguments}) { + ${4:// constructor_body} + } + ${5:// body} + } + +# Arrow Function +snippet () + (${1:first_argument}) => { + ${2:// body} + } + +# Module import +snippet im + import ${1:name} = module('${2:module_name}'); + +# Declare +snippet de + declare ${1:declaration}; + + +## Javascript snippets + +# Prototype +snippet proto + ${1:class_name}.prototype.${2:method_name} = + function(${3:first_argument}) { + ${4:// body...} + }; +# Function +snippet fun + function ${1:function_name} (${2:argument}) { + ${3:// body...} + } +# Anonymous Function +snippet f + function(${1}) {${2}}; +# if +snippet if + if (${1:true}) {${2}} +# if ... else +snippet ife + if (${1:true}) {${2}} + else{${3}} +# tertiary conditional +snippet t + ${1:/* condition */} ? ${2:a} : ${3:b} +# switch +snippet switch + switch(${1:expression}) { + case '${3:case}': + ${4:// code} + break; + ${5} + default: + ${2:// code} + } +# case +snippet case + case '${1:case}': + ${2:// code} + break; + ${3} +# for (...) {...} +snippet for + for (var ${2:i} = 0; $2 < ${1:Things}.length; $2${3:++}) { + ${4:$1[$2]} + }; +# for (...) {...} (Improved Native For-Loop) +snippet forr + for (var ${2:i} = ${1:Things}.length - 1; $2 >= 0; $2${3:--}) { + ${4:$1[$2]} + }; +# while (...) {...} +snippet wh + while (${1:/* condition */}) { + ${2:/* code */} + } +# do...while +snippet do + do { + ${2:/* code */} + } while (${1:/* condition */}); +# Object Method +snippet :f + ${1:method_name}: function(${2:attribute}) { + ${4} + }${3:,} +# setTimeout function +snippet timeout + setTimeout(function() {${3}}${2}, ${1:10}; +# Get Elements +snippet get + getElementsBy${1:TagName}('${2}')${3} +# Get Element +snippet gett + getElementBy${1:Id}('${2}')${3}