Giant blob of minor changes
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-tsserver / snippets / typescript.json
1 {
2   "Constructor": {
3     "prefix": "ctor",
4     "body": ["/**", " *", " */", "constructor() {", "\tsuper();", "\t$0", "}"],
5     "description": "Constructor"
6   },
7   "Class Definition": {
8     "prefix": "class",
9     "body": [
10       "class ${1:name} {",
11       "\tconstructor(${2:parameters}) {",
12       "\t\t$0",
13       "\t}",
14       "}"
15     ],
16     "description": "Class Definition"
17   },
18   "Public Method Definition": {
19     "prefix": "public method",
20     "body": ["/**", " * ${1:name}", " */", "public ${1:name}() {", "\t$0", "}"],
21     "description": "Public Method Definition"
22   },
23   "Private Method Definition": {
24     "prefix": "private method",
25     "body": ["private ${1:name}() {", "\t$0", "}"],
26     "description": "Private Method Definition"
27   },
28   "Import external module.": {
29     "prefix": "import statement",
30     "body": ["import { $0 } from \"${1:module}\";"],
31     "description": "Import external module."
32   },
33   "Property getter": {
34     "prefix": "get",
35     "body": [
36       "",
37       "public get ${1:value}() : ${2:string} {",
38       "\t${3:return $0}",
39       "}",
40       ""
41     ],
42     "description": "Property getter"
43   },
44   "Log to the console": {
45     "prefix": "log",
46     "body": ["console.log($1);", "$0"],
47     "description": "Log to the console"
48   },
49   "Log warning to console": {
50     "prefix": "warn",
51     "body": ["console.warn($1);", "$0"],
52     "description": "Log warning to the console"
53   },
54   "Log error to console": {
55     "prefix": "error",
56     "body": ["console.error($1);", "$0"],
57     "description": "Log error to the console"
58   },
59   "Define a full property": {
60     "prefix": "prop",
61     "body": [
62       "",
63       "private _${1:value} : ${2:string};",
64       "public get ${1:value}() : ${2:string} {",
65       "\treturn this._${1:value};",
66       "}",
67       "public set ${1:value}(v : ${2:string}) {",
68       "\tthis._${1:value} = v;",
69       "}",
70       ""
71     ],
72     "description": "Define a full property"
73   },
74   "Triple-slash reference": {
75     "prefix": "ref",
76     "body": ["/// <reference path=\"$1\" />", "$0"],
77     "description": "Triple-slash reference"
78   },
79   "Property setter": {
80     "prefix": "set",
81     "body": [
82       "",
83       "public set ${1:value}(v : ${2:string}) {",
84       "\tthis.$3 = v;",
85       "}",
86       ""
87     ],
88     "description": "Property setter"
89   },
90   "Throw Exception": {
91     "prefix": "throw",
92     "body": ["throw new Error(\"$1\");", "$0"],
93     "description": "Throw Exception"
94   },
95   "For Loop": {
96     "prefix": "for",
97     "body": [
98       "for (let ${1:index} = 0; ${1:index} < ${2:array}.length; ${1:index}++) {",
99       "\tconst ${3:element} = ${2:array}[${1:index}];",
100       "\t$0",
101       "}"
102     ],
103     "description": "For Loop"
104   },
105   "For-Each Loop using =>": {
106     "prefix": "foreach =>",
107     "body": ["${1:array}.forEach(${2:element} => {", "\t$0", "});"],
108     "description": "For-Each Loop using =>"
109   },
110   "For-In Loop": {
111     "prefix": "forin",
112     "body": [
113       "for (const ${1:key} in ${2:object}) {",
114       "\tif (Object.prototype.hasOwnProperty.call(${2:object}, ${1:key})) {",
115       "\t\tconst ${3:element} = ${2:object}[${1:key}];",
116       "\t\t$0",
117       "\t}",
118       "}"
119     ],
120     "description": "For-In Loop"
121   },
122   "For-Of Loop": {
123     "prefix": "forof",
124     "body": ["for (const ${1:iterator} of ${2:object}) {", "\t$0", "}"],
125     "description": "For-Of Loop"
126   },
127   "For-Await-Of Loop": {
128     "prefix": "forawaitof",
129     "body": ["for await (const ${1:iterator} of ${2:object}) {", "\t$0", "}"],
130     "description": "For-Await-Of Loop"
131   },
132   "Function Statement": {
133     "prefix": "function",
134     "body": ["function ${1:name}(${2:params}:${3:type}) {", "\t$0", "}"],
135     "description": "Function Statement"
136   },
137   "If Statement": {
138     "prefix": "if",
139     "body": ["if (${1:condition}) {", "\t$0", "}"],
140     "description": "If Statement"
141   },
142   "If-Else Statement": {
143     "prefix": "ifelse",
144     "body": ["if (${1:condition}) {", "\t$0", "} else {", "\t", "}"],
145     "description": "If-Else Statement"
146   },
147   "New Statement": {
148     "prefix": "new",
149     "body": ["const ${1:name} = new ${2:type}(${3:arguments});$0"],
150     "description": "New Statement"
151   },
152   "Switch Statement": {
153     "prefix": "switch",
154     "body": [
155       "switch (${1:key}) {",
156       "\tcase ${2:value}:",
157       "\t\t$0",
158       "\t\tbreak;",
159       "",
160       "\tdefault:",
161       "\t\tbreak;",
162       "}"
163     ],
164     "description": "Switch Statement"
165   },
166   "While Statement": {
167     "prefix": "while",
168     "body": ["while (${1:condition}) {", "\t$0", "}"],
169     "description": "While Statement"
170   },
171   "Do-While Statement": {
172     "prefix": "dowhile",
173     "body": ["do {", "\t$0", "} while (${1:condition});"],
174     "description": "Do-While Statement"
175   },
176   "Try-Catch Statement": {
177     "prefix": "trycatch",
178     "body": ["try {", "\t$0", "} catch (${1:error}) {", "\t", "}"],
179     "description": "Try-Catch Statement"
180   },
181   "Set Timeout Function": {
182     "prefix": "settimeout",
183     "body": ["setTimeout(() => {", "\t$0", "}, ${1:timeout});"],
184     "description": "Set Timeout Function"
185   },
186   "Region Start": {
187     "prefix": "#region",
188     "body": ["//#region $0"],
189     "description": "Folding Region Start"
190   },
191   "Region End": {
192     "prefix": "#endregion",
193     "body": ["//#endregion"],
194     "description": "Folding Region End"
195   },
196   "new Promise": {
197     "prefix": "newpromise",
198     "body": ["new Promise<${1:type}>((resolve, reject) => {", "\t$2", "})"],
199     "description": "Create a new Promise"
200   },
201   "Async Function Statement": {
202     "prefix": "async function",
203     "body": ["async function ${1:name}(${2:params}:${3:type}) {", "\t$0", "}"],
204     "description": "Async Function Statement"
205   },
206   "Async Function Expression": {
207     "prefix": "async arrow function",
208     "body": ["async (${1:params}:${2:type}) => {", "\t$0", "}"],
209     "description": "Async Function Expression"
210   }
211 }