- Basic Function: Create a snippet that, when you type
func
, generates a basic TypeScript function declaration. It should include placeholders for the function name, parameters, and return type, with tab stops to easily navigate between them. Add a descriptive label. - Arrow Function: Design a snippet triggered by
arrfunc
that creates a basic TypeScript arrow function. Include placeholders for the variable name, parameters, and return type, with tab stops for navigation. Add a description. - Async Function: Develop a snippet with the prefix
asyncfunc
that generates an asynchronous TypeScript function declaration. It should have placeholders for the function name, parameters, and return type (within aPromise
), and use tab stops for easy editing. Include a description. - Basic Class: Create a snippet that, upon typing
class
, generates a basic TypeScript class structure, including theconstructor
. Use placeholders for the class name and constructor parameters, with tab stops for easy filling. Add a description and ensure it spans multiple lines. - Class Method: Design a snippet with the prefix
classmethod
to generate a public method within a TypeScript class. Include placeholders for the method name, parameters, and return type, with tab stops for navigation. Add a description. - Private Property: Develop a snippet triggered by
privateprop
to quickly declare a private property within a TypeScript class. Include placeholders for the property name and its type, with tab stops. Add a description. - Basic Import: Create a snippet that, when you type
import
, generates a basic TypeScript import statement using curly braces for named imports. Include placeholders for the module name(s) and the import path. Add a description. - Import All: Design a snippet with the prefix
importall
to generate a TypeScript import statement that imports all modules from a path under a given alias. Include placeholders for the alias and the import path. Add a description. - Type Alias: Develop a snippet with the prefix
typealias
to declare a TypeScript type alias. Include placeholders for the type name and the type definition. Add a description. - Promise: Design a snippet with the prefix
promise
to generate a basic structure for creating a newPromise
in TypeScript, including theresolve
andreject
callbacks. Include a placeholder for the Promise’s type and another for the body of the Promise. Ensure it’s multiline and has a description. - Basic
fetch
Request: Create a snippet that, when you typeffetch
, sets up the basic structure for afetch
request in TypeScript. It should include placeholders for the URL, the HTTP method (consider using a choice placeholder for ‘POST’, ‘PUT’, ‘PATCH’, ‘DELETE’, ‘GET’), and an emptybody
(for relevant methods). Include basic error handling with atry
/catch
. Use tab stops to navigate through the URL, method, and body. Add a description. - Import Default Export: Design a snippet triggered by
importdef
that generates a TypeScript import statement specifically for importing thedefault
export from a module. It should include placeholders for the variable name that will hold the default export and the path to the module. Add a description. - Basic Express Route: Develop a snippet with the prefix
expressroute
that lays out the basic structure of an Express route handler in TypeScript. It should include placeholders for the route path, the HTTP method (consider a choice placeholder forget
,post
,put
,patch
,delete
), and the request (req
), response (res
), and next (next
) parameters. Include a basicres.send()
or similar within the handler. Ensure it’s multiline and has a description. - Basic React Component: Create a snippet that, upon typing
rc
, generates the basic structure of a functional React component in TypeScript. It should include placeholders for the component name, and a basic return statement with adiv
or similar. Consider including a basic import forReact
if needed. Ensure it’s multiline and has a description. - File Header Snippet: Create a snippet that, when you type
fileheader
, generates a standard file header comment in TypeScript, automatically including the current filename and the current date. Use the appropriate Visual Studio Code predefined variables for this. Add a description. - Transform to Uppercase: Design a snippet with the prefix
toupper
that takes a word as input through a placeholder and then inserts both the original word and its uppercase version. Use a transform to convert the placeholder text to uppercase. Add a description. - Surround with
try…catch
: Develop a snippet with the prefixtrycatch
that is designed to surround selected TypeScript code with atry…catch
block. It should use the$TM_SELECTED_TEXT
variable to represent the highlighted code. Add a description.
You can take a look at some of the proposed solutions here.