@wooorm/starry-night
Version:
Syntax highlighting, like GitHub
913 lines (912 loc) • 242 kB
JavaScript
// This is a TextMate grammar distributed by `starry-night`.
// This grammar is developed at
// <https://github.com/Microsoft/TypeScript-TmLanguage>
// and licensed `mit`.
// See <https://github.com/wooorm/starry-night> for more info.
/**
* @import {Grammar} from '@wooorm/starry-night'
*/
/** @type {Grammar} */
const grammar = {
extensions: ['.tsx'],
names: ['tsx'],
patterns: [
{include: '#directives'},
{include: '#statements'},
{include: '#shebang'}
],
repository: {
'access-modifier': {
match:
'(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(abstract|declare|override|public|protected|private|readonly|static)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))',
name: 'storage.modifier.tsx'
},
'after-operator-block-as-object-literal': {
begin:
'(?<!\\+\\+|--)(?<=[:=(,\\[?+!>]|^await|[^\\._$[:alnum:]]await|^return|[^\\._$[:alnum:]]return|^yield|[^\\._$[:alnum:]]yield|^throw|[^\\._$[:alnum:]]throw|^in|[^\\._$[:alnum:]]in|^of|[^\\._$[:alnum:]]of|^typeof|[^\\._$[:alnum:]]typeof|&&|\\|\\||\\*)\\s*(\\{)',
beginCaptures: {1: {name: 'punctuation.definition.block.tsx'}},
end: '\\}',
endCaptures: {0: {name: 'punctuation.definition.block.tsx'}},
name: 'meta.objectliteral.tsx',
patterns: [{include: '#object-member'}]
},
'array-binding-pattern': {
begin: '(?:(\\.\\.\\.)\\s*)?(\\[)',
beginCaptures: {
1: {name: 'keyword.operator.rest.tsx'},
2: {name: 'punctuation.definition.binding-pattern.array.tsx'}
},
end: '\\]',
endCaptures: {
0: {name: 'punctuation.definition.binding-pattern.array.tsx'}
},
patterns: [{include: '#binding-element'}, {include: '#punctuation-comma'}]
},
'array-binding-pattern-const': {
begin: '(?:(\\.\\.\\.)\\s*)?(\\[)',
beginCaptures: {
1: {name: 'keyword.operator.rest.tsx'},
2: {name: 'punctuation.definition.binding-pattern.array.tsx'}
},
end: '\\]',
endCaptures: {
0: {name: 'punctuation.definition.binding-pattern.array.tsx'}
},
patterns: [
{include: '#binding-element-const'},
{include: '#punctuation-comma'}
]
},
'array-literal': {
begin: '\\s*(\\[)',
beginCaptures: {1: {name: 'meta.brace.square.tsx'}},
end: '\\]',
endCaptures: {0: {name: 'meta.brace.square.tsx'}},
name: 'meta.array.literal.tsx',
patterns: [{include: '#expression'}, {include: '#punctuation-comma'}]
},
'arrow-function': {
patterns: [
{
captures: {
1: {name: 'storage.modifier.async.tsx'},
2: {name: 'variable.parameter.tsx'}
},
match:
'(?:(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(\\basync)\\s+)?([_$[:alpha:]][_$[:alnum:]]*)\\s*(?==>)',
name: 'meta.arrow.tsx'
},
{
begin:
'(?x) (?:\n (?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(\\basync)\n)? ((?<![})!\\]])\\s*\n (?=\n # sure shot arrow functions even if => is on new line\n(\n (<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<])*\\>)*\\>)*>\\s*)?\n [(]\\s*(\\/\\*([^\\*]|(\\*[^\\/]))*\\*\\/\\s*)*\n (\n ([)]\\s*:) | # ():\n ((\\.\\.\\.\\s*)?[_$[:alpha:]][_$[:alnum:]]*\\s*:) # [(]param: | [(]...param:\n )\n) |\n(\n [<]\\s*[_$[:alpha:]][_$[:alnum:]]*\\s+extends\\s*[^=>] # < typeparam extends\n) |\n# arrow function possible to detect only with => on same line\n(\n (<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<])*\\>)*\\>)*>\\s*)? # typeparameters\n \\(\\s*(\\/\\*([^\\*]|(\\*[^\\/]))*\\*\\/\\s*)*(([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\])|(\\.\\.\\.\\s*[_$[:alpha:]]))([^()\\\'\\"\\`]|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\\'([^\\\'\\\\]|\\\\.)*\\\')|(\\"([^\\"\\\\]|\\\\.)*\\")|(\\`([^\\`\\\\]|\\\\.)*\\`))*)?\\) # parameters\n (\\s*:\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+)? # return type\n \\s*=> # arrow operator\n)\n )\n)',
beginCaptures: {1: {name: 'storage.modifier.async.tsx'}},
end: '(?==>|\\{|(^\\s*(export|function|class|interface|let|var|(?:\\busing(?=\\s+(?!in\\b|of\\b(?!\\s*(?:of\\b|=)))[_$[:alpha:]])\\b)|(?:\\bawait\\s+(?:\\busing(?=\\s+(?!in\\b|of\\b(?!\\s*(?:of\\b|=)))[_$[:alpha:]])\\b)\\b)|const|import|enum|namespace|module|type|abstract|declare)\\s+))',
name: 'meta.arrow.tsx',
patterns: [
{include: '#comment'},
{include: '#type-parameters'},
{include: '#function-parameters'},
{include: '#arrow-return-type'},
{include: '#possibly-arrow-return-type'}
]
},
{
begin: '=>',
beginCaptures: {0: {name: 'storage.type.function.arrow.tsx'}},
end: '((?<=\\}|\\S)(?<!=>)|((?!\\{)(?=\\S)))(?!\\/[\\/\\*])',
name: 'meta.arrow.tsx',
patterns: [
{include: '#single-line-comment-consuming-line-ending'},
{include: '#decl-block'},
{include: '#expression'}
]
}
]
},
'arrow-return-type': {
begin: '(?<=\\))\\s*(:)',
beginCaptures: {1: {name: 'keyword.operator.type.annotation.tsx'}},
end: '(?==>|\\{|(^\\s*(export|function|class|interface|let|var|(?:\\busing(?=\\s+(?!in\\b|of\\b(?!\\s*(?:of\\b|=)))[_$[:alpha:]])\\b)|(?:\\bawait\\s+(?:\\busing(?=\\s+(?!in\\b|of\\b(?!\\s*(?:of\\b|=)))[_$[:alpha:]])\\b)\\b)|const|import|enum|namespace|module|type|abstract|declare)\\s+))',
name: 'meta.return.type.arrow.tsx',
patterns: [{include: '#arrow-return-type-body'}]
},
'arrow-return-type-body': {
patterns: [
{
begin: '(?<=[:])(?=\\s*\\{)',
end: '(?<=\\})',
patterns: [{include: '#type-object'}]
},
{include: '#type-predicate-operator'},
{include: '#type'}
]
},
'async-modifier': {
match:
'(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(async)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))',
name: 'storage.modifier.async.tsx'
},
'binding-element': {
patterns: [
{include: '#comment'},
{include: '#string'},
{include: '#numeric-literal'},
{include: '#regex'},
{include: '#object-binding-pattern'},
{include: '#array-binding-pattern'},
{include: '#destructuring-variable-rest'},
{include: '#variable-initializer'}
]
},
'binding-element-const': {
patterns: [
{include: '#comment'},
{include: '#string'},
{include: '#numeric-literal'},
{include: '#regex'},
{include: '#object-binding-pattern-const'},
{include: '#array-binding-pattern-const'},
{include: '#destructuring-variable-rest-const'},
{include: '#variable-initializer'}
]
},
'boolean-literal': {
patterns: [
{
match:
'(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))true(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))',
name: 'constant.language.boolean.true.tsx'
},
{
match:
'(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))false(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))',
name: 'constant.language.boolean.false.tsx'
}
]
},
brackets: {
patterns: [
{begin: '{', end: '}|(?=\\*/)', patterns: [{include: '#brackets'}]},
{begin: '\\[', end: '\\]|(?=\\*/)', patterns: [{include: '#brackets'}]}
]
},
cast: {patterns: [{include: '#jsx'}]},
'class-declaration': {
begin:
'(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(\\bexport)\\s+)?(?:(\\bdeclare)\\s+)?\\b(?:(abstract)\\s+)?\\b(class)\\b(?=\\s+|/[/*])',
beginCaptures: {
1: {name: 'keyword.control.export.tsx'},
2: {name: 'storage.modifier.tsx'},
3: {name: 'storage.modifier.tsx'},
4: {name: 'storage.type.class.tsx'}
},
end: '(?<=\\})',
name: 'meta.class.tsx',
patterns: [{include: '#class-declaration-or-expression-patterns'}]
},
'class-declaration-or-expression-patterns': {
patterns: [
{include: '#comment'},
{include: '#class-or-interface-heritage'},
{
captures: {0: {name: 'entity.name.type.class.tsx'}},
match: '[_$[:alpha:]][_$[:alnum:]]*'
},
{include: '#type-parameters'},
{include: '#class-or-interface-body'}
]
},
'class-expression': {
begin:
'(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(abstract)\\s+)?(class)\\b(?=\\s+|[<{]|\\/[\\/*])',
beginCaptures: {
1: {name: 'storage.modifier.tsx'},
2: {name: 'storage.type.class.tsx'}
},
end: '(?<=\\})',
name: 'meta.class.tsx',
patterns: [{include: '#class-declaration-or-expression-patterns'}]
},
'class-or-interface-body': {
begin: '\\{',
beginCaptures: {0: {name: 'punctuation.definition.block.tsx'}},
end: '\\}',
endCaptures: {0: {name: 'punctuation.definition.block.tsx'}},
patterns: [
{include: '#comment'},
{include: '#decorator'},
{
begin: '(?<=:)\\s*',
end: '(?=\\s|[;),}\\]:\\-\\+]|;|^\\s*$|(?:^\\s*(?:abstract|async|(?:\\bawait\\s+(?:\\busing(?=\\s+(?!in\\b|of\\b(?!\\s*(?:of\\b|=)))[_$[:alpha:]])\\b)\\b)|break|case|catch|class|const|continue|declare|do|else|enum|export|finally|function|for|goto|if|import|interface|let|module|namespace|switch|return|throw|try|type|(?:\\busing(?=\\s+(?!in\\b|of\\b(?!\\s*(?:of\\b|=)))[_$[:alpha:]])\\b)|var|while)\\b))',
patterns: [{include: '#expression'}]
},
{include: '#method-declaration'},
{include: '#indexer-declaration'},
{include: '#field-declaration'},
{include: '#string'},
{include: '#type-annotation'},
{include: '#variable-initializer'},
{include: '#access-modifier'},
{include: '#property-accessor'},
{include: '#async-modifier'},
{include: '#after-operator-block-as-object-literal'},
{include: '#decl-block'},
{include: '#expression'},
{include: '#punctuation-comma'},
{include: '#punctuation-semicolon'}
]
},
'class-or-interface-heritage': {
begin:
'(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:\\b(extends|implements)\\b)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))',
beginCaptures: {1: {name: 'storage.modifier.tsx'}},
end: '(?=\\{)',
patterns: [
{include: '#comment'},
{include: '#class-or-interface-heritage'},
{include: '#type-parameters'},
{include: '#expressionWithoutIdentifiers'},
{
captures: {
1: {name: 'entity.name.type.module.tsx'},
2: {name: 'punctuation.accessor.tsx'},
3: {name: 'punctuation.accessor.optional.tsx'}
},
match:
'([_$[:alpha:]][_$[:alnum:]]*)\\s*(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))(?=\\s*[_$[:alpha:]][_$[:alnum:]]*(\\s*\\??\\.\\s*[_$[:alpha:]][_$[:alnum:]]*)*\\s*)'
},
{
captures: {1: {name: 'entity.other.inherited-class.tsx'}},
match: '([_$[:alpha:]][_$[:alnum:]]*)'
},
{include: '#expressionPunctuations'}
]
},
comment: {
patterns: [
{
begin: '/\\*\\*(?!/)',
beginCaptures: {0: {name: 'punctuation.definition.comment.tsx'}},
end: '\\*/',
endCaptures: {0: {name: 'punctuation.definition.comment.tsx'}},
name: 'comment.block.documentation.tsx',
patterns: [{include: '#docblock'}]
},
{
begin: '(/\\*)(?:\\s*((@)internal)(?=\\s|(\\*/)))?',
beginCaptures: {
1: {name: 'punctuation.definition.comment.tsx'},
2: {name: 'storage.type.internaldeclaration.tsx'},
3: {name: 'punctuation.decorator.internaldeclaration.tsx'}
},
end: '\\*/',
endCaptures: {0: {name: 'punctuation.definition.comment.tsx'}},
name: 'comment.block.tsx'
},
{
begin: '(^[ \\t]+)?((//)(?:\\s*((@)internal)(?=\\s|$))?)',
beginCaptures: {
1: {name: 'punctuation.whitespace.comment.leading.tsx'},
2: {name: 'comment.line.double-slash.tsx'},
3: {name: 'punctuation.definition.comment.tsx'},
4: {name: 'storage.type.internaldeclaration.tsx'},
5: {name: 'punctuation.decorator.internaldeclaration.tsx'}
},
contentName: 'comment.line.double-slash.tsx',
end: '(?=$)'
}
]
},
'control-statement': {
patterns: [
{include: '#switch-statement'},
{include: '#for-loop'},
{
match:
'(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(catch|finally|throw|try)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))',
name: 'keyword.control.trycatch.tsx'
},
{
captures: {
1: {name: 'keyword.control.loop.tsx'},
2: {name: 'entity.name.label.tsx'}
},
match:
'(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(break|continue|goto)\\s+([_$[:alpha:]][_$[:alnum:]]*)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))'
},
{
match:
'(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(break|continue|do|goto|while)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))',
name: 'keyword.control.loop.tsx'
},
{
begin:
'(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(return)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))',
beginCaptures: {0: {name: 'keyword.control.flow.tsx'}},
end: '(?=[;}]|$|;|^\\s*$|(?:^\\s*(?:abstract|async|(?:\\bawait\\s+(?:\\busing(?=\\s+(?!in\\b|of\\b(?!\\s*(?:of\\b|=)))[_$[:alpha:]])\\b)\\b)|break|case|catch|class|const|continue|declare|do|else|enum|export|finally|function|for|goto|if|import|interface|let|module|namespace|switch|return|throw|try|type|(?:\\busing(?=\\s+(?!in\\b|of\\b(?!\\s*(?:of\\b|=)))[_$[:alpha:]])\\b)|var|while)\\b))',
patterns: [{include: '#expression'}]
},
{
match:
'(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(case|default|switch)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))',
name: 'keyword.control.switch.tsx'
},
{include: '#if-statement'},
{
match:
'(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(else|if)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))',
name: 'keyword.control.conditional.tsx'
},
{
match:
'(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(with)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))',
name: 'keyword.control.with.tsx'
},
{
match:
'(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(package)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))',
name: 'keyword.control.tsx'
},
{
match:
'(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(debugger)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))',
name: 'keyword.other.debugger.tsx'
}
]
},
'decl-block': {
begin: '\\{',
beginCaptures: {0: {name: 'punctuation.definition.block.tsx'}},
end: '\\}',
endCaptures: {0: {name: 'punctuation.definition.block.tsx'}},
name: 'meta.block.tsx',
patterns: [{include: '#statements'}]
},
declaration: {
patterns: [
{include: '#decorator'},
{include: '#var-expr'},
{include: '#function-declaration'},
{include: '#class-declaration'},
{include: '#interface-declaration'},
{include: '#enum-declaration'},
{include: '#namespace-declaration'},
{include: '#type-alias-declaration'},
{include: '#import-equals-declaration'},
{include: '#import-declaration'},
{include: '#export-declaration'},
{
match:
'(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(declare|export)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))',
name: 'storage.modifier.tsx'
}
]
},
decorator: {
begin: '(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))\\@',
beginCaptures: {0: {name: 'punctuation.decorator.tsx'}},
end: '(?=\\s)',
name: 'meta.decorator.tsx',
patterns: [{include: '#expression'}]
},
'destructuring-const': {
patterns: [
{
begin:
'(?<!=|:|^of|[^\\._$[:alnum:]]of|^in|[^\\._$[:alnum:]]in)\\s*(?=\\{)',
end: '(?=$|^|[;,=}]|((?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(of|in)\\s+))',
name: 'meta.object-binding-pattern-variable.tsx',
patterns: [
{include: '#object-binding-pattern-const'},
{include: '#type-annotation'},
{include: '#comment'}
]
},
{
begin:
'(?<!=|:|^of|[^\\._$[:alnum:]]of|^in|[^\\._$[:alnum:]]in)\\s*(?=\\[)',
end: '(?=$|^|[;,=}]|((?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(of|in)\\s+))',
name: 'meta.array-binding-pattern-variable.tsx',
patterns: [
{include: '#array-binding-pattern-const'},
{include: '#type-annotation'},
{include: '#comment'}
]
}
]
},
'destructuring-parameter': {
patterns: [
{
begin: '(?<!=|:)\\s*(?:(\\.\\.\\.)\\s*)?(\\{)',
beginCaptures: {
1: {name: 'keyword.operator.rest.tsx'},
2: {name: 'punctuation.definition.binding-pattern.object.tsx'}
},
end: '\\}',
endCaptures: {
0: {name: 'punctuation.definition.binding-pattern.object.tsx'}
},
name: 'meta.parameter.object-binding-pattern.tsx',
patterns: [{include: '#parameter-object-binding-element'}]
},
{
begin: '(?<!=|:)\\s*(?:(\\.\\.\\.)\\s*)?(\\[)',
beginCaptures: {
1: {name: 'keyword.operator.rest.tsx'},
2: {name: 'punctuation.definition.binding-pattern.array.tsx'}
},
end: '\\]',
endCaptures: {
0: {name: 'punctuation.definition.binding-pattern.array.tsx'}
},
name: 'meta.paramter.array-binding-pattern.tsx',
patterns: [
{include: '#parameter-binding-element'},
{include: '#punctuation-comma'}
]
}
]
},
'destructuring-parameter-rest': {
captures: {
1: {name: 'keyword.operator.rest.tsx'},
2: {name: 'variable.parameter.tsx'}
},
match: '(?:(\\.\\.\\.)\\s*)?([_$[:alpha:]][_$[:alnum:]]*)'
},
'destructuring-variable': {
patterns: [
{
begin:
'(?<!=|:|^of|[^\\._$[:alnum:]]of|^in|[^\\._$[:alnum:]]in)\\s*(?=\\{)',
end: '(?=$|^|[;,=}]|((?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(of|in)\\s+))',
name: 'meta.object-binding-pattern-variable.tsx',
patterns: [
{include: '#object-binding-pattern'},
{include: '#type-annotation'},
{include: '#comment'}
]
},
{
begin:
'(?<!=|:|^of|[^\\._$[:alnum:]]of|^in|[^\\._$[:alnum:]]in)\\s*(?=\\[)',
end: '(?=$|^|[;,=}]|((?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(of|in)\\s+))',
name: 'meta.array-binding-pattern-variable.tsx',
patterns: [
{include: '#array-binding-pattern'},
{include: '#type-annotation'},
{include: '#comment'}
]
}
]
},
'destructuring-variable-rest': {
captures: {
1: {name: 'keyword.operator.rest.tsx'},
2: {name: 'meta.definition.variable.tsx variable.other.readwrite.tsx'}
},
match: '(?:(\\.\\.\\.)\\s*)?([_$[:alpha:]][_$[:alnum:]]*)'
},
'destructuring-variable-rest-const': {
captures: {
1: {name: 'keyword.operator.rest.tsx'},
2: {name: 'meta.definition.variable.tsx variable.other.constant.tsx'}
},
match: '(?:(\\.\\.\\.)\\s*)?([_$[:alpha:]][_$[:alnum:]]*)'
},
directives: {
begin:
'^(///)\\s*(?=<(reference|amd-dependency|amd-module)(\\s+(path|types|no-default-lib|lib|name|resolution-mode)\\s*=\\s*((\\\'([^\\\'\\\\]|\\\\.)*\\\')|(\\"([^\\"\\\\]|\\\\.)*\\")|(\\`([^\\`\\\\]|\\\\.)*\\`)))+\\s*/>\\s*$)',
beginCaptures: {1: {name: 'punctuation.definition.comment.tsx'}},
end: '(?=$)',
name: 'comment.line.triple-slash.directive.tsx',
patterns: [
{
begin: '(<)(reference|amd-dependency|amd-module)',
beginCaptures: {
1: {name: 'punctuation.definition.tag.directive.tsx'},
2: {name: 'entity.name.tag.directive.tsx'}
},
end: '/>',
endCaptures: {0: {name: 'punctuation.definition.tag.directive.tsx'}},
name: 'meta.tag.tsx',
patterns: [
{
match: 'path|types|no-default-lib|lib|name|resolution-mode',
name: 'entity.other.attribute-name.directive.tsx'
},
{match: '=', name: 'keyword.operator.assignment.tsx'},
{include: '#string'}
]
}
]
},
docblock: {
patterns: [
{
captures: {
1: {name: 'storage.type.class.jsdoc'},
2: {name: 'punctuation.definition.block.tag.jsdoc'},
3: {name: 'constant.language.access-type.jsdoc'}
},
match:
'(?x)\n((@)(?:access|api))\n\\s+\n(private|protected|public)\n\\b'
},
{
captures: {
1: {name: 'storage.type.class.jsdoc'},
2: {name: 'punctuation.definition.block.tag.jsdoc'},
3: {name: 'entity.name.type.instance.jsdoc'},
4: {name: 'punctuation.definition.bracket.angle.begin.jsdoc'},
5: {name: 'constant.other.email.link.underline.jsdoc'},
6: {name: 'punctuation.definition.bracket.angle.end.jsdoc'}
},
match:
'(?x)\n((@)author)\n\\s+\n(\n [^@\\s<>*/]\n (?:[^@<>*/]|\\*[^/])*\n)\n(?:\n \\s*\n (<)\n ([^>\\s]+)\n (>)\n)?'
},
{
captures: {
1: {name: 'storage.type.class.jsdoc'},
2: {name: 'punctuation.definition.block.tag.jsdoc'},
3: {name: 'entity.name.type.instance.jsdoc'},
4: {name: 'keyword.operator.control.jsdoc'},
5: {name: 'entity.name.type.instance.jsdoc'}
},
match:
'(?x)\n((@)borrows) \\s+\n((?:[^@\\s*/]|\\*[^/])+) # <that namepath>\n\\s+ (as) \\s+ # as\n((?:[^@\\s*/]|\\*[^/])+) # <this namepath>'
},
{
begin: '((@)example)\\s+',
beginCaptures: {
1: {name: 'storage.type.class.jsdoc'},
2: {name: 'punctuation.definition.block.tag.jsdoc'}
},
end: '(?=@|\\*/)',
name: 'meta.example.jsdoc',
patterns: [
{match: '^\\s\\*\\s+'},
{
begin: '\\G(<)caption(>)',
beginCaptures: {
0: {name: 'entity.name.tag.inline.jsdoc'},
1: {name: 'punctuation.definition.bracket.angle.begin.jsdoc'},
2: {name: 'punctuation.definition.bracket.angle.end.jsdoc'}
},
contentName: 'constant.other.description.jsdoc',
end: '(</)caption(>)|(?=\\*/)',
endCaptures: {
0: {name: 'entity.name.tag.inline.jsdoc'},
1: {name: 'punctuation.definition.bracket.angle.begin.jsdoc'},
2: {name: 'punctuation.definition.bracket.angle.end.jsdoc'}
}
},
{
captures: {0: {name: 'source.embedded.tsx'}},
match: '[^\\s@*](?:[^*]|\\*[^/])*'
}
]
},
{
captures: {
1: {name: 'storage.type.class.jsdoc'},
2: {name: 'punctuation.definition.block.tag.jsdoc'},
3: {name: 'constant.language.symbol-type.jsdoc'}
},
match:
'(?x) ((@)kind) \\s+ (class|constant|event|external|file|function|member|mixin|module|namespace|typedef) \\b'
},
{
captures: {
1: {name: 'storage.type.class.jsdoc'},
2: {name: 'punctuation.definition.block.tag.jsdoc'},
3: {name: 'variable.other.link.underline.jsdoc'},
4: {name: 'entity.name.type.instance.jsdoc'}
},
match:
'(?x)\n((@)see)\n\\s+\n(?:\n # URL\n (\n (?=https?://)\n (?:[^\\s*]|\\*[^/])+\n )\n |\n # JSDoc namepath\n (\n (?!\n # Avoid matching bare URIs (also acceptable as links)\n https?://\n |\n # Avoid matching {@inline tags}; we match those below\n (?:\\[[^\\[\\]]*\\])? # Possible description [preceding]{@tag}\n {@(?:link|linkcode|linkplain|tutorial)\\b\n )\n # Matched namepath\n (?:[^@\\s*/]|\\*[^/])+\n )\n)'
},
{
captures: {
1: {name: 'storage.type.class.jsdoc'},
2: {name: 'punctuation.definition.block.tag.jsdoc'},
3: {name: 'variable.other.jsdoc'}
},
match:
'(?x)\n((@)template)\n\\s+\n# One or more valid identifiers\n(\n [A-Za-z_$] # First character: non-numeric word character\n [\\w$.\\[\\]]* # Rest of identifier\n (?: # Possible list of additional identifiers\n \\s* , \\s*\n [A-Za-z_$]\n [\\w$.\\[\\]]*\n )*\n)'
},
{
begin: '(?x)((@)template)\\s+(?={)',
beginCaptures: {
1: {name: 'storage.type.class.jsdoc'},
2: {name: 'punctuation.definition.block.tag.jsdoc'}
},
end: '(?=\\s|\\*/|[^{}\\[\\]A-Za-z_$])',
patterns: [
{include: '#jsdoctype'},
{match: '([A-Za-z_$][\\w$.\\[\\]]*)', name: 'variable.other.jsdoc'}
]
},
{
captures: {
1: {name: 'storage.type.class.jsdoc'},
2: {name: 'punctuation.definition.block.tag.jsdoc'},
3: {name: 'variable.other.jsdoc'}
},
match:
'(?x)\n(\n (@)\n (?:arg|argument|const|constant|member|namespace|param|var)\n)\n\\s+\n(\n [A-Za-z_$]\n [\\w$.\\[\\]]*\n)'
},
{
begin: '((@)typedef)\\s+(?={)',
beginCaptures: {
1: {name: 'storage.type.class.jsdoc'},
2: {name: 'punctuation.definition.block.tag.jsdoc'}
},
end: '(?=\\s|\\*/|[^{}\\[\\]A-Za-z_$])',
patterns: [
{include: '#jsdoctype'},
{
match: '(?:[^@\\s*/]|\\*[^/])+',
name: 'entity.name.type.instance.jsdoc'
}
]
},
{
begin:
'((@)(?:arg|argument|const|constant|member|namespace|param|prop|property|var))\\s+(?={)',
beginCaptures: {
1: {name: 'storage.type.class.jsdoc'},
2: {name: 'punctuation.definition.block.tag.jsdoc'}
},
end: '(?=\\s|\\*/|[^{}\\[\\]A-Za-z_$])',
patterns: [
{include: '#jsdoctype'},
{match: '([A-Za-z_$][\\w$.\\[\\]]*)', name: 'variable.other.jsdoc'},
{
captures: {
1: {
name: 'punctuation.definition.optional-value.begin.bracket.square.jsdoc'
},
2: {name: 'keyword.operator.assignment.jsdoc'},
3: {name: 'source.embedded.tsx'},
4: {
name: 'punctuation.definition.optional-value.end.bracket.square.jsdoc'
},
5: {name: 'invalid.illegal.syntax.jsdoc'}
},
match:
'(?x)\n(\\[)\\s*\n[\\w$]+\n(?:\n (?:\\[\\])? # Foo[ ].bar properties within an array\n \\. # Foo.Bar namespaced parameter\n [\\w$]+\n)*\n(?:\n \\s*\n (=) # [foo=bar] Default parameter value\n \\s*\n (\n # The inner regexes are to stop the match early at */ and to not stop at escaped quotes\n (?>\n "(?:(?:\\*(?!/))|(?:\\\\(?!"))|[^*\\\\])*?" | # [foo="bar"] Double-quoted\n \'(?:(?:\\*(?!/))|(?:\\\\(?!\'))|[^*\\\\])*?\' | # [foo=\'bar\'] Single-quoted\n \\[ (?:(?:\\*(?!/))|[^*])*? \\] | # [foo=[1,2]] Array literal\n (?:(?:\\*(?!/))|\\s(?!\\s*\\])|\\[.*?(?:\\]|(?=\\*/))|[^*\\s\\[\\]])* # Everything else\n )*\n )\n)?\n\\s*(?:(\\])((?:[^*\\s]|\\*[^\\s/])+)?|(?=\\*/))',
name: 'variable.other.jsdoc'
}
]
},
{
begin:
'(?x)\n(\n (@)\n (?:define|enum|exception|export|extends|lends|implements|modifies\n |namespace|private|protected|returns?|satisfies|suppress|this|throws|type\n |yields?)\n)\n\\s+(?={)',
beginCaptures: {
1: {name: 'storage.type.class.jsdoc'},
2: {name: 'punctuation.definition.block.tag.jsdoc'}
},
end: '(?=\\s|\\*/|[^{}\\[\\]A-Za-z_$])',
patterns: [{include: '#jsdoctype'}]
},
{
captures: {
1: {name: 'storage.type.class.jsdoc'},
2: {name: 'punctuation.definition.block.tag.jsdoc'},
3: {name: 'entity.name.type.instance.jsdoc'}
},
match:
'(?x)\n(\n (@)\n (?:alias|augments|callback|constructs|emits|event|fires|exports?\n |extends|external|function|func|host|lends|listens|interface|memberof!?\n |method|module|mixes|mixin|name|requires|see|this|typedef|uses)\n)\n\\s+\n(\n (?:\n [^{}@\\s*] | \\*[^/]\n )+\n)'
},
{
begin: "((@)(?:default(?:value)?|license|version))\\s+(([''\"]))",
beginCaptures: {
1: {name: 'storage.type.class.jsdoc'},
2: {name: 'punctuation.definition.block.tag.jsdoc'},
3: {name: 'variable.other.jsdoc'},
4: {name: 'punctuation.definition.string.begin.jsdoc'}
},
contentName: 'variable.other.jsdoc',
end: '(\\3)|(?=$|\\*/)',
endCaptures: {
0: {name: 'variable.other.jsdoc'},
1: {name: 'punctuation.definition.string.end.jsdoc'}
}
},
{
captures: {
1: {name: 'storage.type.class.jsdoc'},
2: {name: 'punctuation.definition.block.tag.jsdoc'},
3: {name: 'variable.other.jsdoc'}
},
match:
'((@)(?:default(?:value)?|license|tutorial|variation|version))\\s+([^\\s*]+)'
},
{
captures: {1: {name: 'punctuation.definition.block.tag.jsdoc'}},
match:
'(?x) (@) (?:abstract|access|alias|api|arg|argument|async|attribute|augments|author|beta|borrows|bubbles |callback|chainable|class|classdesc|code|config|const|constant|constructor|constructs|copyright |default|defaultvalue|define|deprecated|desc|description|dict|emits|enum|event|example|exception |exports?|extends|extension(?:_?for)?|external|externs|file|fileoverview|final|fires|for|func |function|generator|global|hideconstructor|host|ignore|implements|implicitCast|inherit[Dd]oc |inner|instance|interface|internal|kind|lends|license|listens|main|member|memberof!?|method |mixes|mixins?|modifies|module|name|namespace|noalias|nocollapse|nocompile|nosideeffects |override|overview|package|param|polymer(?:Behavior)?|preserve|private|prop|property|protected |public|read[Oo]nly|record|require[ds]|returns?|see|since|static|struct|submodule|summary |suppress|template|this|throws|todo|tutorial|type|typedef|unrestricted|uses|var|variation |version|virtual|writeOnce|yields?) \\b',
name: 'storage.type.class.jsdoc'
},
{include: '#inline-tags'},
{
captures: {
1: {name: 'storage.type.class.jsdoc'},
2: {name: 'punctuation.definition.block.tag.jsdoc'}
},
match: '((@)(?:[_$[:alpha:]][_$[:alnum:]]*))(?=\\s+)'
}
]
},
'enum-declaration': {
begin:
'(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(\\bexport)\\s+)?(?:(\\bdeclare)\\s+)?(?:\\b(const)\\s+)?\\b(enum)\\s+([_$[:alpha:]][_$[:alnum:]]*)',
beginCaptures: {
1: {name: 'keyword.control.export.tsx'},
2: {name: 'storage.modifier.tsx'},
3: {name: 'storage.modifier.tsx'},
4: {name: 'storage.type.enum.tsx'},
5: {name: 'entity.name.type.enum.tsx'}
},
end: '(?<=\\})',
name: 'meta.enum.declaration.tsx',
patterns: [
{include: '#comment'},
{
begin: '\\{',
beginCaptures: {0: {name: 'punctuation.definition.block.tsx'}},
end: '\\}',
endCaptures: {0: {name: 'punctuation.definition.block.tsx'}},
patterns: [
{include: '#comment'},
{
begin: '([_$[:alpha:]][_$[:alnum:]]*)',
beginCaptures: {0: {name: 'variable.other.enummember.tsx'}},
end: '(?=,|\\}|$)',
patterns: [
{include: '#comment'},
{include: '#variable-initializer'}
]
},
{
begin:
'(?=((\\\'([^\\\'\\\\]|\\\\.)*\\\')|(\\"([^\\"\\\\]|\\\\.)*\\")|(\\`([^\\`\\\\]|\\\\.)*\\`)|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])+\\])))',
end: '(?=,|\\}|$)',
patterns: [
{include: '#string'},
{include: '#array-literal'},
{include: '#comment'},
{include: '#variable-initializer'}
]
},
{include: '#punctuation-comma'}
]
}
]
},
'export-declaration': {
patterns: [
{
captures: {
1: {name: 'keyword.control.export.tsx'},
2: {name: 'keyword.control.as.tsx'},
3: {name: 'storage.type.namespace.tsx'},
4: {name: 'entity.name.type.module.tsx'}
},
match:
'(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(export)\\s+(as)\\s+(namespace)\\s+([_$[:alpha:]][_$[:alnum:]]*)'
},
{
begin:
'(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(export)(?:\\s+(type))?(?:(?:\\s*(=))|(?:\\s+(default)(?=\\s+)))',
beginCaptures: {
1: {name: 'keyword.control.export.tsx'},
2: {name: 'keyword.control.type.tsx'},
3: {name: 'keyword.operator.assignment.tsx'},
4: {name: 'keyword.control.default.tsx'}
},
end: '(?=$|;|^\\s*$|(?:^\\s*(?:abstract|async|(?:\\bawait\\s+(?:\\busing(?=\\s+(?!in\\b|of\\b(?!\\s*(?:of\\b|=)))[_$[:alpha:]])\\b)\\b)|break|case|catch|class|const|continue|declare|do|else|enum|export|finally|function|for|goto|if|import|interface|let|module|namespace|switch|return|throw|try|type|(?:\\busing(?=\\s+(?!in\\b|of\\b(?!\\s*(?:of\\b|=)))[_$[:alpha:]])\\b)|var|while)\\b))',
name: 'meta.export.default.tsx',
patterns: [
{include: '#interface-declaration'},
{include: '#expression'}
]
},
{
begin:
'(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(export)(?:\\s+(type))?\\b(?!(\\$)|(\\s*:))((?=\\s*[\\{*])|((?=\\s*[_$[:alpha:]][_$[:alnum:]]*(\\s|,))(?!\\s*(?:abstract|async|(?:\\bawait\\s+(?:\\busing(?=\\s+(?!in\\b|of\\b(?!\\s*(?:of\\b|=)))[_$[:alpha:]])\\b)\\b)|break|case|catch|class|const|continue|declare|do|else|enum|export|finally|function|for|goto|if|import|interface|let|module|namespace|switch|return|throw|try|type|(?:\\busing(?=\\s+(?!in\\b|of\\b(?!\\s*(?:of\\b|=)))[_$[:alpha:]])\\b)|var|while)\\b)))',
beginCaptures: {
1: {name: 'keyword.control.export.tsx'},
2: {name: 'keyword.control.type.tsx'}
},
end: '(?=$|;|^\\s*$|(?:^\\s*(?:abstract|async|(?:\\bawait\\s+(?:\\busing(?=\\s+(?!in\\b|of\\b(?!\\s*(?:of\\b|=)))[_$[:alpha:]])\\b)\\b)|break|case|catch|class|const|continue|declare|do|else|enum|export|finally|function|for|goto|if|import|interface|let|module|namespace|switch|return|throw|try|type|(?:\\busing(?=\\s+(?!in\\b|of\\b(?!\\s*(?:of\\b|=)))[_$[:alpha:]])\\b)|var|while)\\b))',
name: 'meta.export.tsx',
patterns: [{include: '#import-export-declaration'}]
}
]
},
expression: {
patterns: [
{include: '#expressionWithoutIdentifiers'},
{include: '#identifiers'},
{include: '#expressionPunctuations'}
]
},
'expression-inside-possibly-arrow-parens': {
patterns: [
{include: '#expressionWithoutIdentifiers'},
{include: '#comment'},
{include: '#string'},
{include: '#decorator'},
{include: '#destructuring-parameter'},
{
captures: {1: {name: 'storage.modifier.tsx'}},
match:
'(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(override|public|protected|private|readonly)\\s+(?=(override|public|protected|private|readonly)\\s+)'
},
{
captures: {
1: {name: 'storage.modifier.tsx'},
2: {name: 'keyword.operator.rest.tsx'},
3: {name: 'entity.name.function.tsx variable.language.this.tsx'},
4: {name: 'entity.name.function.tsx'},
5: {name: 'keyword.operator.optional.tsx'}
},
match:
'(?x)(?:(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(override|public|private|protected|readonly)\\s+)?(?:(\\.\\.\\.)\\s*)?(?<!=|:)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(this)|([_$[:alpha:]][_$[:alnum:]]*))(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))\\s*(\\??)(?=\\s*\n# function assignment |\n(=\\s*(\n ((async\\s+)?(\n (function\\s*[(<*]) |\n (function\\s+) |\n ([_$[:alpha:]][_$[:alnum:]]*\\s*=>)\n )) |\n ((async\\s*)?(\n ((<\\s*$)|([\\(]\\s*((([\\{\\[]\\s*)?$)|((\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})\\s*((:\\s*\\{?$)|((\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+\\s*)?=\\s*)))|((\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\])\\s*((:\\s*\\[?$)|((\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+\\s*)?=\\s*)))))) |\n # sure shot arrow functions even if => is on new line\n(\n (<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<])*\\>)*\\>)*>\\s*)?\n [(]\\s*(\\/\\*([^\\*]|(\\*[^\\/]))*\\*\\/\\s*)*\n (\n ([)]\\s*:) | # ():\n ((\\.\\.\\.\\s*)?[_$[:alpha:]][_$[:alnum:]]*\\s*:) # [(]param: | [(]...param:\n )\n) |\n(\n [<]\\s*[_$[:alpha:]][_$[:alnum:]]*\\s+extends\\s*[^=>] # < typeparam extends\n) |\n# arrow function possible to detect only with => on same line\n(\n (<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<])*\\>)*\\>)*>\\s*)? # typeparameters\n \\(\\s*(\\/\\*([^\\*]|(\\*[^\\/]))*\\*\\/\\s*)*(([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\])|(\\.\\.\\.\\s*[_$[:alpha:]]))([^()\\\'\\"\\`]|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\\'([^\\\'\\\\]|\\\\.)*\\\')|(\\"([^\\"\\\\]|\\\\.)*\\")|(\\`([^\\`\\\\]|\\\\.)*\\`))*)?\\) # parameters\n (\\s*:\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+)? # return type\n \\s*=> # arrow operator\n)\n ))\n)) |\n# typeannotation is fn type: < | () | (... | (param: | (param, | (param? | (param= | (param) =>\n(:\\s*(\n (<) |\n ([(]\\s*(\n ([)]) |\n (\\.\\.\\.) |\n ([_$[:alnum:]]+\\s*(\n ([:,?=])|\n ([)]\\s*=>)\n ))\n ))\n)) |\n(:\\s*(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))Function(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))) |\n(:\\s*((<\\s*$)|([\\(]\\s*((([\\{\\[]\\s*)?$)|((\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})\\s*((:\\s*\\{?$)|((\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+\\s*)?=\\s*)))|((\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\])\\s*((:\\s*\\[?$)|((\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+\\s*)?=\\s*))))))) |\n(:\\s*(=>|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(<[^<>]*>)|[^<>(),=])+=\\s*(\n ((async\\s+)?(\n (function\\s*[(<*]) |\n (function\\s+) |\n ([_$[:alpha:]][_$[:alnum:]]*\\s*=>)\n )) |\n ((async\\s*)?(\n ((<\\s*$)|([\\(]\\s*((([\\{\\[]\\s*)?$)|((\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})\\s*((:\\s*\\{?$)|((\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+\\s*)?=\\s*)))|((\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\])\\s*((:\\s*\\[?$)|((\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+\\s*)?=\\s*)))))) |\n # sure shot arrow functions even if => is on new line\n(\n (<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<])*\\>)*\\>)*>\\s*)?\n [(]\\s*(\\/\\*([^\\*]|(\\*[^\\/]))*\\*\\/\\s*)*\n (\n ([)]\\s*:) | # ():\n ((\\.\\.\\.\\s*)?[_$[:alpha:]][_$[:alnum:]]*\\s*:) # [(]param: | [(]...param:\n )\n) |\n(\n [<]\\s*[_$[:alpha:]][_$[:alnum:]]*\\s+extends\\s*[^=>] # < typeparam extends\n) |\n# arrow function possible to detect only with => on same line\n(\n (<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<])*\\>)*\\>)*>\\s*)? # typeparameters\n \\(\\s*(\\/\\*([^\\*]|(\\*[^\\/]))*\\*\\/\\s*)*(([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\])|(\\.\\.\\.\\s*[_$[:alpha:]]))([^()\\\'\\"\\`]|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\\'([^\\\'\\\\]|\\\\.)*\\\')|(\\"([^\\"\\\\]|\\\\.)*\\")|(\\`([^\\`\\\\]|\\\\.)*\\`))*)?\\) # parameters\n (\\s*:\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+)? # return type\n \\s*=> # arrow operator\n)\n ))\n)))'
},
{
captures: {
1: {name: 'storage.modifier.tsx'},
2: {name: 'keyword.operator.rest.tsx'},
3: {name: 'variable.parameter.tsx variable.language.this.tsx'},
4: {name: 'variable.parameter.tsx'},
5: {name: 'keyword.operator.optional.tsx'}
},
match:
'(?x)(?:(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(override|public|private|protected|readonly)\\s+)?(?:(\\.\\.\\.)\\s*)?(?<!=|:)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(this)|([_$[:alpha:]][_$[:alnum:]]*))(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))\\s*(\\??)(?=\\s*[:,]|$)'
},
{include: '#type-annotation'},
{include: '#variable-initializer'},
{match: ',', name: 'punctuation.separator.parameter.tsx'},
{include: '#identifiers'},
{include: '#expressionPunctuations'}
]
},
'expression-operators': {
patterns: [
{
match:
'(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(await)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))',
name: 'keyword.control.flow.tsx'
},
{
begin:
'(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(yield)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))(?=\\s*\\/\\*([^\\*]|(\\*[^\\/]))*\\*\\/\\s*\\*)',
beginCaptures: {1: {name: 'keyword.control.flow.tsx'}},
end: '\\*',
endCaptures: {0: {name: 'keyword.generator.asterisk.tsx'}},
patterns: [{include: '#comment'}]
},
{
captures: {
1: {name: 'keyword.control.flow.tsx'},
2: {name: 'keyword.generator.asterisk.tsx'}
},
match:
'(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(yield)(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))(?:\\s*(\\*))?'
},
{
match:
'(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))delete(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))',
name: 'keyword.operator.expression.delete.tsx'
},
{
match:
'(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))in(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.))(?!\\()',
name: 'keyword.operator.expression.in.tsx'
},
{
match:
'(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))of(?![_$[:alnum: