- 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
arrfuncthat 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
asyncfuncthat 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
classmethodto 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
privatepropto 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
importallto 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
typealiasto 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
promiseto generate a basic structure for creating a newPromisein TypeScript, including theresolveandrejectcallbacks. 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
fetchRequest: Create a snippet that, when you typeffetch, sets up the basic structure for afetchrequest 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
importdefthat generates a TypeScript import statement specifically for importing thedefaultexport 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
expressroutethat 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 adivor similar. Consider including a basic import forReactif 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
toupperthat 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 prefixtrycatchthat is designed to surround selected TypeScript code with atry…catchblock. It should use the$TM_SELECTED_TEXTvariable to represent the highlighted code. Add a description.
You can take a look at some of the proposed solutions here.