ReSharper 2024.2 Help

Predefined Live Templates for TypeScript

This topic lists all predefined live templates for TypeScript in ReSharper 2024.2. For more information about live templates, refer to Create source code using live templates.

Template

Details

ctx

Current file context

Scope Everywhere

Body

$CTX$

Parameters

  • CTX - Provides a list of items describing current context. This includes file name, containing type name, namespace name, etc.

nguid

Insert new GUID

Scope Everywhere

Body

$GUID$

Parameters

  • GUID - Generates a new Globally Unique Identifier (GUID)

do

do...while loop

Scope JS statements

Body

do { $END$ } while($COND$)

Parameters

  • COND - no macro

  • END - The caret position after the template is applied.

dw

writeln function call

Scope JS statements

Body

document.writeln($END$);

Parameters

  • END - The caret position after the template is applied.

else

else statement

Scope JS statements

Body

else { $END$ }

Parameters

  • END - The caret position after the template is applied.

for

for loop

Scope JS statements (ES 6)

Body

for ($VARKIND$ $VAR$ = 0; $VAR$ < $LENGTH$; $VAR$++){ $END$ }

Parameters

  • VAR - Suggests a unique name for an index variable at the evaluation point

  • LENGTH - no macro

  • VARKIND - Displays the specified list of values in the completion list

  • END - The caret position after the template is applied.

forin

for...in loop

Scope JS statements (ES 6)

Body

for ($VARKIND$ $VAR$ in $ARRAY$){ $END$ }

Parameters

  • ARRAY - no macro

  • VAR - When executed in a variable declaration (where variable name should stand), suggests a name for the variable

  • VARKIND - Displays the specified list of values in the completion list

  • END - The caret position after the template is applied.

forr

reverse for loop

Scope JS statements (ES 6)

Body

for ($VARKIND$ $VAR$=$LENGTH$-1;$VAR$ >=0; $VAR$--){ $END$ }

Parameters

  • VAR - Suggests a unique name for an index variable at the evaluation point

  • LENGTH - no macro

  • VARKIND - Displays the specified list of values in the completion list

  • END - The caret position after the template is applied.

fun

Create TypeScript function

Scope JS expressions

Body

function($parameters$){ $END$ }

Parameters

  • parameters - no macro

  • END - The caret position after the template is applied.

Before expansion

ReSharper: Live templates

After expansion

ReSharper: Live templates

function

Scope JS statements

Body

function $name$($parameters$){ $END$ }

Parameters

  • name - no macro

  • parameters - no macro

  • END - The caret position after the template is applied.

if

if statement

Scope JS statements

Body

if ($COND$){ $END$ }

Parameters

  • COND - no macro

  • END - The caret position after the template is applied.

while

while loop

Scope JS statements

Body

while ($COND$){ $END$ }

Parameters

  • COND - no macro

  • END - The caret position after the template is applied.

with

with statement

Scope JS statements

Body

with ($EXPR$){ $END$ }

Parameters

  • EXPR - no macro

  • END - The caret position after the template is applied.

switch

switch statement

Scope JS statements

Body

switch ($EXPR$){ case $CASE1$: $END$ default: }

Parameters

  • EXPR - no macro

  • CASE1 - no macro

  • END - The caret position after the template is applied.

try

try catch statement

Scope JS statements

Body

try { $END$ } catch (e) { }

Parameters

  • END - The caret position after the template is applied.

itar

Iterate an array

Scope JS statements

Body

for (var $INDEX$=0;$INDEX$<$ARRAY$.length;$INDEX$++){ var $VAR$ = $ARRAY$[$INDEX$];$END$ }

Parameters

  • ARRAY - no macro

  • INDEX - Suggests a unique name for an index variable at the evaluation point

  • VAR - When executed in a variable declaration (where variable name should stand), suggests a name for the variable

  • END - The caret position after the template is applied.

Before expansion

ReSharper: Live templates

After expansion

ReSharper: Live templates

forof

for-of loop

Scope JS statements (ES 6)

Body

for ($VARKIND$ $VAR$ of $ARRAY$){ $END$ }

Parameters

  • VAR - When executed in a variable declaration (where variable name should stand), suggests a name for the variable

  • ARRAY - no macro

  • VARKIND - Displays the specified list of values in the completion list

  • END - The caret position after the template is applied.

ctor

Code snippet for default constructor declaration with body

Scope TS type members

Body

constructor() { $END$ }

Parameters

  • END - The caret position after the template is applied.

class

Code snippet for class

Scope TS module members

Body

class $Name$ { $END$ }

Parameters

  • Name - no macro

  • END - The caret position after the template is applied.

module

Code snippet for module

Scope TS module members

Body

module $Name$ { $END$ }

Parameters

  • Name - no macro

  • END - The caret position after the template is applied.

interface

Code snippet for interface

Scope TS module members

Body

interface I$Name$ { $END$ }

Parameters

  • Name - no macro

  • END - The caret position after the template is applied.

enum

Code snippet for enum

Scope TS module members

Body

enum $Name$ { $END$ }

Parameters

  • Name - no macro

  • END - The caret position after the template is applied.

nidx

Code snippet for number indexer annotation

Scope TS type members

Body

[index: number]: $Type$;

Parameters

  • Type - Shows basic code completion list at the point where the variable is evaluated

sidx

Code snippet for string indexer annotation

Scope TS type members

Body

[index: string]: $Type$;

Parameters

  • Type - Shows basic code completion list at the point where the variable is evaluated

prop

Code snippet for property

Scope TS type members

Body

get $Name$():$Type$ {$BODY1$} set $Name$(value:$Type$) {$END$}

Parameters

  • Name - no macro

  • Type - Shows basic code completion list at the point where the variable is evaluated

  • BODY1 - Evaluates to the specified constant value

  • END - The caret position after the template is applied.

Last modified: 18 August 2024