mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-20 02:08:47 +00:00
Align JS and TS snippets (#219917)
Mostly should be the same with a few small differences
This commit is contained in:
@@ -1,16 +1,79 @@
|
|||||||
{
|
{
|
||||||
"define module": {
|
"Constructor": {
|
||||||
"prefix": "define",
|
"prefix": "ctor",
|
||||||
"body": [
|
"body": [
|
||||||
"define([",
|
"/**",
|
||||||
"\t'require',",
|
" *",
|
||||||
"\t'${1:dependency}'",
|
" */",
|
||||||
"], function(require, ${2:factory}) {",
|
"constructor() {",
|
||||||
"\t'use strict';",
|
"\tsuper();",
|
||||||
"\t$0",
|
"\t$0",
|
||||||
"});"
|
"}"
|
||||||
],
|
],
|
||||||
"description": "define module"
|
"description": "Constructor"
|
||||||
|
},
|
||||||
|
"Class Definition": {
|
||||||
|
"prefix": "class",
|
||||||
|
"isFileTemplate": true,
|
||||||
|
"body": [
|
||||||
|
"class ${1:name} {",
|
||||||
|
"\tconstructor(${2:parameters}) {",
|
||||||
|
"\t\t$0",
|
||||||
|
"\t}",
|
||||||
|
"}"
|
||||||
|
],
|
||||||
|
"description": "Class Definition"
|
||||||
|
},
|
||||||
|
"Method Definition": {
|
||||||
|
"prefix": "method",
|
||||||
|
"body": [
|
||||||
|
"/**",
|
||||||
|
" * ",
|
||||||
|
" */",
|
||||||
|
"${1:name}() {",
|
||||||
|
"\t$0",
|
||||||
|
"}"
|
||||||
|
],
|
||||||
|
"description": "Method Definition"
|
||||||
|
},
|
||||||
|
"Import Statement": {
|
||||||
|
"prefix": "import",
|
||||||
|
"body": [
|
||||||
|
"import { $0 } from \"${1:module}\";"
|
||||||
|
],
|
||||||
|
"description": "Import external module"
|
||||||
|
},
|
||||||
|
"Log to the console": {
|
||||||
|
"prefix": "log",
|
||||||
|
"body": [
|
||||||
|
"console.log($1);",
|
||||||
|
"$0"
|
||||||
|
],
|
||||||
|
"description": "Log to the console"
|
||||||
|
},
|
||||||
|
"Log warning to console": {
|
||||||
|
"prefix": "warn",
|
||||||
|
"body": [
|
||||||
|
"console.warn($1);",
|
||||||
|
"$0"
|
||||||
|
],
|
||||||
|
"description": "Log warning to the console"
|
||||||
|
},
|
||||||
|
"Log error to console": {
|
||||||
|
"prefix": "error",
|
||||||
|
"body": [
|
||||||
|
"console.error($1);",
|
||||||
|
"$0"
|
||||||
|
],
|
||||||
|
"description": "Log error to the console"
|
||||||
|
},
|
||||||
|
"Throw Exception": {
|
||||||
|
"prefix": "throw",
|
||||||
|
"body": [
|
||||||
|
"throw new Error(\"$1\");",
|
||||||
|
"$0"
|
||||||
|
],
|
||||||
|
"description": "Throw Exception"
|
||||||
},
|
},
|
||||||
"For Loop": {
|
"For Loop": {
|
||||||
"prefix": "for",
|
"prefix": "for",
|
||||||
@@ -22,20 +85,20 @@
|
|||||||
],
|
],
|
||||||
"description": "For Loop"
|
"description": "For Loop"
|
||||||
},
|
},
|
||||||
"For-Each Loop": {
|
"For-Each Loop using =>": {
|
||||||
"prefix": "foreach",
|
"prefix": "foreach =>",
|
||||||
"body": [
|
"body": [
|
||||||
"${1:array}.forEach(${2:element} => {",
|
"${1:array}.forEach(${2:element} => {",
|
||||||
"\t$TM_SELECTED_TEXT$0",
|
"\t$TM_SELECTED_TEXT$0",
|
||||||
"});"
|
"});"
|
||||||
],
|
],
|
||||||
"description": "For-Each Loop"
|
"description": "For-Each Loop using =>"
|
||||||
},
|
},
|
||||||
"For-In Loop": {
|
"For-In Loop": {
|
||||||
"prefix": "forin",
|
"prefix": "forin",
|
||||||
"body": [
|
"body": [
|
||||||
"for (const ${1:key} in ${2:object}) {",
|
"for (const ${1:key} in ${2:object}) {",
|
||||||
"\tif (Object.hasOwnProperty.call(${2:object}, ${1:key})) {",
|
"\tif (Object.prototype.hasOwnProperty.call(${2:object}, ${1:key})) {",
|
||||||
"\t\tconst ${3:element} = ${2:object}[${1:key}];",
|
"\t\tconst ${3:element} = ${2:object}[${1:key}];",
|
||||||
"\t\t$TM_SELECTED_TEXT$0",
|
"\t\t$TM_SELECTED_TEXT$0",
|
||||||
"\t}",
|
"\t}",
|
||||||
@@ -52,6 +115,15 @@
|
|||||||
],
|
],
|
||||||
"description": "For-Of Loop"
|
"description": "For-Of Loop"
|
||||||
},
|
},
|
||||||
|
"For-Await-Of Loop": {
|
||||||
|
"prefix": "forawaitof",
|
||||||
|
"body": [
|
||||||
|
"for await (const ${1:element} of ${2:object}) {",
|
||||||
|
"\t$TM_SELECTED_TEXT$0",
|
||||||
|
"}"
|
||||||
|
],
|
||||||
|
"description": "For-Await-Of Loop"
|
||||||
|
},
|
||||||
"Function Statement": {
|
"Function Statement": {
|
||||||
"prefix": "function",
|
"prefix": "function",
|
||||||
"body": [
|
"body": [
|
||||||
@@ -149,13 +221,6 @@
|
|||||||
],
|
],
|
||||||
"description": "Set Interval Function"
|
"description": "Set Interval Function"
|
||||||
},
|
},
|
||||||
"Import Statement": {
|
|
||||||
"prefix": "import",
|
|
||||||
"body": [
|
|
||||||
"import { $0 } from \"${1:module}\";"
|
|
||||||
],
|
|
||||||
"description": "Import external module"
|
|
||||||
},
|
|
||||||
"Region Start": {
|
"Region Start": {
|
||||||
"prefix": "#region",
|
"prefix": "#region",
|
||||||
"body": [
|
"body": [
|
||||||
@@ -170,27 +235,6 @@
|
|||||||
],
|
],
|
||||||
"description": "Folding Region End"
|
"description": "Folding Region End"
|
||||||
},
|
},
|
||||||
"Log to the console": {
|
|
||||||
"prefix": "log",
|
|
||||||
"body": [
|
|
||||||
"console.log($1);"
|
|
||||||
],
|
|
||||||
"description": "Log to the console"
|
|
||||||
},
|
|
||||||
"Log warning to console": {
|
|
||||||
"prefix": "warn",
|
|
||||||
"body": [
|
|
||||||
"console.warn($1);"
|
|
||||||
],
|
|
||||||
"description": "Log warning to the console"
|
|
||||||
},
|
|
||||||
"Log error to console": {
|
|
||||||
"prefix": "error",
|
|
||||||
"body": [
|
|
||||||
"console.error($1);"
|
|
||||||
],
|
|
||||||
"description": "Log error to the console"
|
|
||||||
},
|
|
||||||
"new Promise": {
|
"new Promise": {
|
||||||
"prefix": "newpromise",
|
"prefix": "newpromise",
|
||||||
"body": [
|
"body": [
|
||||||
@@ -199,5 +243,23 @@
|
|||||||
"})"
|
"})"
|
||||||
],
|
],
|
||||||
"description": "Create a new Promise"
|
"description": "Create a new Promise"
|
||||||
|
},
|
||||||
|
"Async Function Statement": {
|
||||||
|
"prefix": "async function",
|
||||||
|
"body": [
|
||||||
|
"async function ${1:name}(${2:params}) {",
|
||||||
|
"\t$TM_SELECTED_TEXT$0",
|
||||||
|
"}"
|
||||||
|
],
|
||||||
|
"description": "Async Function Statement"
|
||||||
|
},
|
||||||
|
"Async Function Expression": {
|
||||||
|
"prefix": "async arrow function",
|
||||||
|
"body": [
|
||||||
|
"async (${1:params}) => {",
|
||||||
|
"\t$TM_SELECTED_TEXT$0",
|
||||||
|
"}"
|
||||||
|
],
|
||||||
|
"description": "Async Function Expression"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -266,6 +266,15 @@
|
|||||||
],
|
],
|
||||||
"description": "Set Timeout Function"
|
"description": "Set Timeout Function"
|
||||||
},
|
},
|
||||||
|
"Set Interval Function": {
|
||||||
|
"prefix": "setinterval",
|
||||||
|
"body": [
|
||||||
|
"setInterval(() => {",
|
||||||
|
"\t$TM_SELECTED_TEXT$0",
|
||||||
|
"}, ${1:interval});"
|
||||||
|
],
|
||||||
|
"description": "Set Interval Function"
|
||||||
|
},
|
||||||
"Region Start": {
|
"Region Start": {
|
||||||
"prefix": "#region",
|
"prefix": "#region",
|
||||||
"body": [
|
"body": [
|
||||||
|
|||||||
Reference in New Issue
Block a user