summaryrefslogtreecommitdiffstats
path: root/assets/syntaxes/02_Extra/TypsecriptReact.sublime-syntax
diff options
context:
space:
mode:
Diffstat (limited to 'assets/syntaxes/02_Extra/TypsecriptReact.sublime-syntax')
-rw-r--r--assets/syntaxes/02_Extra/TypsecriptReact.sublime-syntax1373
1 files changed, 896 insertions, 477 deletions
diff --git a/assets/syntaxes/02_Extra/TypsecriptReact.sublime-syntax b/assets/syntaxes/02_Extra/TypsecriptReact.sublime-syntax
index 05ab04e6..1b57bb14 100644
--- a/assets/syntaxes/02_Extra/TypsecriptReact.sublime-syntax
+++ b/assets/syntaxes/02_Extra/TypsecriptReact.sublime-syntax
@@ -9,10 +9,7 @@ contexts:
main:
- include: directives
- include: statements
- - match: \A(#!).*(?=$)
- scope: comment.line.shebang.ts
- captures:
- 1: punctuation.definition.comment.ts
+ - include: shebang
comment:
- match: /\*\*(?!/)
captures:
@@ -44,10 +41,10 @@ contexts:
5: punctuation.decorator.internaldeclaration.tsx
push:
- meta_content_scope: comment.line.double-slash.tsx
- - match: (?=^)
+ - match: (?=$)
pop: true
access-modifier:
- - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(abstract|public|protected|private|readonly|static)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))'
+ - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(abstract|declare|override|public|protected|private|readonly|static)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))'
scope: storage.modifier.tsx
after-operator-block-as-object-literal:
- match: '(?<!\+\+|--)(?<=[:=(,\[?+!>]|^await|[^\._$[:alnum:]]await|^return|[^\._$[:alnum:]]return|^yield|[^\._$[:alnum:]]yield|^throw|[^\._$[:alnum:]]throw|^in|[^\._$[:alnum:]]in|^of|[^\._$[:alnum:]]of|^typeof|[^\._$[:alnum:]]typeof|&&|\|\||\*)\s*(\{)'
@@ -109,8 +106,8 @@ contexts:
(?=
# sure shot arrow functions even if => is on new line
(
- (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*>\s*)?
- [(]\s*
+ (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?
+ [(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*
(
([)]\s*:) | # ():
((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param:
@@ -121,9 +118,9 @@ contexts:
) |
# arrow function possible to detect only with => on same line
(
- (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*>\s*)? # typeparameters
- \(\s*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()]|(\(([^\(\)]|(\([^\(\)]*\)))*\)))*)?\) # parameters
- (\s*:\s*([^<>\(\)]|\<[^<>]+\>|\([^\(\)]+\))+)? # return type
+ (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters
+ \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()\'\"\`]|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\'([^\'\\]|\\.)*\')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))*)?\) # parameters
+ (\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type
\s*=> # arrow operator
)
)
@@ -138,13 +135,15 @@ contexts:
- include: type-parameters
- include: function-parameters
- include: arrow-return-type
+ - include: possibly-arrow-return-type
- match: "=>"
captures:
0: storage.type.function.arrow.tsx
push:
- meta_scope: meta.arrow.tsx
- - match: '(?<=\}|\S)(?<!=>)|((?!\{)(?=\S))'
+ - match: '((?<=\}|\S)(?<!=>)|((?!\{)(?=\S)))(?!\/[\/\*])'
pop: true
+ - include: single-line-comment-consuming-line-ending
- include: decl-block
- include: expression
arrow-return-type:
@@ -170,6 +169,8 @@ contexts:
binding-element:
- include: comment
- include: string
+ - include: numeric-literal
+ - include: regex
- include: object-binding-pattern
- include: array-binding-pattern
- include: destructuring-variable-rest
@@ -177,6 +178,8 @@ contexts:
binding-element-const:
- include: comment
- include: string
+ - include: numeric-literal
+ - include: regex
- include: object-binding-pattern-const
- include: array-binding-pattern-const
- include: destructuring-variable-rest-const
@@ -200,11 +203,12 @@ contexts:
cast:
- include: jsx
class-declaration:
- - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(export)\s+)?\b(?:(abstract)\s+)?\b(class)\b(?=\s+|/[/*])'
+ - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(\bexport)\s+)?(?:(\bdeclare)\s+)?\b(?:(abstract)\s+)?\b(class)\b(?=\s+|/[/*])'
captures:
1: keyword.control.export.tsx
2: storage.modifier.tsx
- 3: storage.type.class.tsx
+ 3: storage.modifier.tsx
+ 4: storage.type.class.tsx
push:
- meta_scope: meta.class.tsx
- match: '(?<=\})'
@@ -219,9 +223,10 @@ contexts:
- include: type-parameters
- include: class-or-interface-body
class-expression:
- - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(class)\b(?=\s+|[<{]|\/[\/*])'
+ - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(abstract)\s+)?(class)\b(?=\s+|[<{]|\/[\/*])'
captures:
- 1: storage.type.class.tsx
+ 1: storage.modifier.tsx
+ 2: storage.type.class.tsx
push:
- meta_scope: meta.class.tsx
- match: '(?<=\})'
@@ -238,6 +243,11 @@ contexts:
pop: true
- include: comment
- include: decorator
+ - match: (?<=:)\s*
+ push:
+ - match: '(?=\s|[;),}\]:\-\+]|;|^\s*$|(?:^\s*(?:abstract|async|class|const|declare|enum|export|function|import|interface|let|module|namespace|return|type|var)\b))'
+ pop: true
+ - include: expression
- include: method-declaration
- include: indexer-declaration
- include: field-declaration
@@ -284,9 +294,15 @@ contexts:
- match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(break|continue|do|goto|while)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))'
scope: keyword.control.loop.tsx
- match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(return)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))'
- scope: keyword.control.flow.tsx
+ captures:
+ 0: keyword.control.flow.tsx
+ push:
+ - match: '(?=[;}]|$|;|^\s*$|(?:^\s*(?:abstract|async|class|const|declare|enum|export|function|import|interface|let|module|namespace|return|type|var)\b))'
+ pop: true
+ - include: expression
- match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(case|default|switch)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))'
scope: keyword.control.switch.tsx
+ - include: if-statement
- match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(else|if)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))'
scope: keyword.control.conditional.tsx
- match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(with)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))'
@@ -295,8 +311,6 @@ contexts:
scope: keyword.control.tsx
- match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(debugger)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))'
scope: keyword.other.debugger.tsx
- - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(declare)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))'
- scope: storage.modifier.tsx
decl-block:
- match: '\{'
captures:
@@ -320,6 +334,8 @@ contexts:
- include: import-equals-declaration
- include: import-declaration
- include: export-declaration
+ - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(declare|export)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))'
+ scope: storage.modifier.tsx
decorator:
- match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))\@'
captures:
@@ -333,7 +349,7 @@ contexts:
- match: '(?<!=|:|^of|[^\._$[:alnum:]]of|^in|[^\._$[:alnum:]]in)\s*(?=\{)'
push:
- meta_scope: meta.object-binding-pattern-variable.tsx
- - match: '(?=$|^|[;,=}]|(\s+(of|in)\s+))'
+ - match: '(?=$|^|[;,=}]|((?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(of|in)\s+))'
pop: true
- include: object-binding-pattern-const
- include: type-annotation
@@ -341,15 +357,16 @@ contexts:
- match: '(?<!=|:|^of|[^\._$[:alnum:]]of|^in|[^\._$[:alnum:]]in)\s*(?=\[)'
push:
- meta_scope: meta.array-binding-pattern-variable.tsx
- - match: '(?=$|^|[;,=}]|(\s+(of|in)\s+))'
+ - match: '(?=$|^|[;,=}]|((?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(of|in)\s+))'
pop: true
- include: array-binding-pattern-const
- include: type-annotation
- include: comment
destructuring-parameter:
- - match: '(?<!=|:)\s*(\{)'
+ - match: '(?<!=|:)\s*(?:(\.\.\.)\s*)?(\{)'
captures:
- 1: punctuation.definition.binding-pattern.object.tsx
+ 1: keyword.operator.rest.tsx
+ 2: punctuation.definition.binding-pattern.object.tsx
push:
- meta_scope: meta.parameter.object-binding-pattern.tsx
- match: '\}'
@@ -357,9 +374,10 @@ contexts:
0: punctuation.definition.binding-pattern.object.tsx
pop: true
- include: parameter-object-binding-element
- - match: '(?<!=|:)\s*(\[)'
+ - match: '(?<!=|:)\s*(?:(\.\.\.)\s*)?(\[)'
captures:
- 1: punctuation.definition.binding-pattern.array.tsx
+ 1: keyword.operator.rest.tsx
+ 2: punctuation.definition.binding-pattern.array.tsx
push:
- meta_scope: meta.paramter.array-binding-pattern.tsx
- match: '\]'
@@ -377,7 +395,7 @@ contexts:
- match: '(?<!=|:|^of|[^\._$[:alnum:]]of|^in|[^\._$[:alnum:]]in)\s*(?=\{)'
push:
- meta_scope: meta.object-binding-pattern-variable.tsx
- - match: '(?=$|^|[;,=}]|(\s+(of|in)\s+))'
+ - match: '(?=$|^|[;,=}]|((?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(of|in)\s+))'
pop: true
- include: object-binding-pattern
- include: type-annotation
@@ -385,7 +403,7 @@ contexts:
- match: '(?<!=|:|^of|[^\._$[:alnum:]]of|^in|[^\._$[:alnum:]]in)\s*(?=\[)'
push:
- meta_scope: meta.array-binding-pattern-variable.tsx
- - match: '(?=$|^|[;,=}]|(\s+(of|in)\s+))'
+ - match: '(?=$|^|[;,=}]|((?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(of|in)\s+))'
pop: true
- include: array-binding-pattern
- include: type-annotation
@@ -401,12 +419,12 @@ contexts:
1: keyword.operator.rest.tsx
2: meta.definition.variable.tsx variable.other.constant.tsx
directives:
- - match: '^(///)\s*(?=<(reference|amd-dependency|amd-module)(\s+(path|types|no-default-lib|lib|name)\s*=\s*((\''([^\''\\]|\\\''|\\)*\'')|(\"([^\"\\]|\\\"|\\)*\")))+\s*/>\s*$)'
+ - match: '^(///)\s*(?=<(reference|amd-dependency|amd-module)(\s+(path|types|no-default-lib|lib|name)\s*=\s*((\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`)))+\s*/>\s*$)'
captures:
1: punctuation.definition.comment.tsx
push:
- meta_scope: comment.line.triple-slash.directive.tsx
- - match: (?=^)
+ - match: (?=$)
pop: true
- match: (<)(reference|amd-dependency|amd-module)
captures:
@@ -668,13 +686,18 @@ contexts:
captures:
1: punctuation.definition.block.tag.jsdoc
- include: inline-tags
+ - match: '((@)(?:[_$[:alpha:]][_$[:alnum:]]*))(?=\s+)'
+ captures:
+ 1: storage.type.class.jsdoc
+ 2: punctuation.definition.block.tag.jsdoc
enum-declaration:
- - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(\bexport)\s+)?(?:\b(const)\s+)?\b(enum)\s+([_$[:alpha:]][_$[:alnum:]]*)'
+ - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(\bexport)\s+)?(?:(\bdeclare)\s+)?(?:\b(const)\s+)?\b(enum)\s+([_$[:alpha:]][_$[:alnum:]]*)'
captures:
1: keyword.control.export.tsx
2: storage.modifier.tsx
- 3: storage.type.enum.tsx
- 4: entity.name.type.enum.tsx
+ 3: storage.modifier.tsx
+ 4: storage.type.enum.tsx
+ 5: entity.name.type.enum.tsx
push:
- meta_scope: meta.enum.declaration.tsx
- match: '(?<=\})'
@@ -697,7 +720,7 @@ contexts:
pop: true
- include: comment
- include: variable-initializer
- - match: '(?=((\''([^\''\\]|\\\''|\\)*\'')|(\"([^\"\\]|\\\"|\\)*\")|(\[([^\[\]]|\[[^\[\]]*\])+\])))'
+ - match: '(?=((\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`)|(\[([^\[\]]|\[[^\[\]]*\])+\])))'
push:
- match: '(?=,|\}|$)'
pop: true
@@ -713,22 +736,25 @@ contexts:
2: keyword.control.as.tsx
3: storage.type.namespace.tsx
4: entity.name.type.module.tsx
- - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(export)(?:(?:\s*(=))|(?:\s+(default)(?=\s+)))'
+ - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(export)(?:\s+(type))?(?:(?:\s*(=))|(?:\s+(default)(?=\s+)))'
captures:
1: keyword.control.export.tsx
- 2: keyword.operator.assignment.tsx
- 3: keyword.control.default.tsx
+ 2: keyword.control.type.tsx
+ 3: keyword.operator.assignment.tsx
+ 4: keyword.control.default.tsx
push:
- meta_scope: meta.export.default.tsx
- - match: (?=$|;|^\s*abstract\b|^\s*async\b|^\s*class\b|^\s*const\b|^\s*declare\b|^\s*enum\b|^\s*export\b|^\s*function\b|^\s*import\b|^\s*interface\b|^\s*let\b|^\s*module\b|^\s*namespace\b|^\s*return\b|^\s*type\b|^\s*var\b)
+ - match: (?=$|;|^\s*$|(?:^\s*(?:abstract|async|class|const|declare|enum|export|function|import|interface|let|module|namespace|return|type|var)\b))
pop: true
+ - include: interface-declaration
- include: expression
- - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(export)(?!\s*:)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))'
+ - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(export)(?:\s+(type))?\b(?!(\$)|(\s*:))((?=\s*[\{*])|((?=\s*[_$[:alpha:]][_$[:alnum:]]*(\s|,))(?!\s*(?:abstract|async|class|const|declare|enum|export|function|import|interface|let|module|namespace|return|type|var)\b)))'
captures:
- 0: keyword.control.export.tsx
+ 1: keyword.control.export.tsx
+ 2: keyword.control.type.tsx
push:
- meta_scope: meta.export.tsx
- - match: (?=$|;|^\s*abstract\b|^\s*async\b|^\s*class\b|^\s*const\b|^\s*declare\b|^\s*enum\b|^\s*export\b|^\s*function\b|^\s*import\b|^\s*interface\b|^\s*let\b|^\s*module\b|^\s*namespace\b|^\s*return\b|^\s*type\b|^\s*var\b)
+ - match: (?=$|;|^\s*$|(?:^\s*(?:abstract|async|class|const|declare|enum|export|function|import|interface|let|module|namespace|return|type|var)\b))
pop: true
- include: import-export-declaration
expression:
@@ -737,7 +763,105 @@ contexts:
- include: expressionPunctuations
expression-inside-possibly-arrow-parens:
- include: expressionWithoutIdentifiers
- - include: function-parameters-body
+ - include: comment
+ - include: string
+ - include: decorator
+ - include: destructuring-parameter
+ - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(override|public|protected|private|readonly)\s+(?=(override|public|protected|private|readonly)\s+)'
+ captures:
+ 1: storage.modifier.tsx
+ - match: |-
+ (?x)(?:(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(override|public|private|protected|readonly)\s+)?(?:(\.\.\.)\s*)?(?<!=|:)(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(this)|([_$[:alpha:]][_$[:alnum:]]*))(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))\s*(\??)(?=\s*
+ # function assignment |
+ (=\s*(
+ ((async\s+)?(
+ (function\s*[(<*]) |
+ (function\s+) |
+ ([_$[:alpha:]][_$[:alnum:]]*\s*=>)
+ )) |
+ ((async\s*)?(
+ ((<\s*$)|([\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))) |
+ # sure shot arrow functions even if => is on new line
+ (
+ (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?
+ [(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*
+ (
+ ([)]\s*:) | # ():
+ ((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param:
+ )
+ ) |
+ (
+ [<]\s*[_$[:alpha:]][_$[:alnum:]]*\s+extends\s*[^=>] # < typeparam extends
+ ) |
+ # arrow function possible to detect only with => on same line
+ (
+ (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters
+ \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()\'\"\`]|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\'([^\'\\]|\\.)*\')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))*)?\) # parameters
+ (\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type
+ \s*=> # arrow operator
+ )
+ ))
+ )) |
+ # typeannotation is fn type: < | () | (... | (param: | (param, | (param? | (param= | (param) =>
+ (:\s*(
+ (<) |
+ ([(]\s*(
+ ([)]) |
+ (\.\.\.) |
+ ([_$[:alnum:]]+\s*(
+ ([:,?=])|
+ ([)]\s*=>)
+ ))
+ ))
+ )) |
+ (:\s*(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))Function(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))) |
+ (:\s*((<\s*$)|([\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*))))))) |
+ (:\s*(=>|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(<[^<>]*>)|[^<>(),=])+=\s*(
+ ((async\s+)?(
+ (function\s*[(<*]) |
+ (function\s+) |
+ ([_$[:alpha:]][_$[:alnum:]]*\s*=>)
+ )) |
+ ((async\s*)?(
+ ((<\s*$)|([\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))) |
+ # sure shot arrow functions even if => is on new line
+ (
+ (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?
+ [(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*
+ (
+ ([)]\s*:) | # ():
+ ((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param:
+ )
+ ) |
+ (
+ [<]\s*[_$[:alpha:]][_$[:alnum:]]*\s+extends\s*[^=>] # < typeparam extends
+ ) |
+ # arrow function possible to detect only with => on same line
+ (
+ (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters
+ \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()\'\"\`]|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\'([^\'\\]|\\.)*\')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))*)?\) # parameters
+ (\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type
+ \s*=> # arrow operator
+ )
+ ))
+ )))
+ captures:
+ 1: storage.modifier.tsx
+ 2: keyword.operator.rest.tsx
+ 3: entity.name.function.tsx variable.language.this.tsx
+ 4: entity.name.function.tsx
+ 5: keyword.operator.optional.tsx
+ - match: '(?x)(?:(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(override|public|private|protected|readonly)\s+)?(?:(\.\.\.)\s*)?(?<!=|:)(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(this)|([_$[:alpha:]][_$[:alnum:]]*))(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))\s*(\??)(?=\s*[:,]|$)'
+ captures:
+ 1: storage.modifier.tsx
+ 2: keyword.operator.rest.tsx
+ 3: variable.parameter.tsx variable.language.this.tsx
+ 4: variable.parameter.tsx
+ 5: keyword.operator.optional.tsx
+ - include: type-annotation
+ - include: variable-initializer
+ - match: ","
+ scope: punctuation.separator.parameter.tsx
- include: identifiers
- include: expressionPunctuations
expression-operators:
@@ -769,11 +893,15 @@ contexts:
- include: typeof-operator
- match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))void(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))'
scope: keyword.operator.expression.void.tsx
+ - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(as)\s+(const)(?=\s*($|[;,:})\]]))'
+ captures:
+ 1: keyword.control.as.tsx
+ 2: storage.modifier.tsx
- match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(as)\s+'
captures:
1: keyword.control.as.tsx
push:
- - match: '(?=$|^|[;,:})\]]|((?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(as)\s+))'
+ - match: '(?=^|[;),}\]:?\-\+\>]|\|\||\&\&|\!\=\=|$|((?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(as)\s+)|(\s+\<))'
pop: true
- include: type
- match: \.\.\.
@@ -788,7 +916,12 @@ contexts:
scope: keyword.operator.comparison.tsx
- match: <=|>=|<>|<|>
scope: keyword.operator.relational.tsx
- - match: \!|&&|\|\|
+ - match: '(?<=[_$[:alnum:]])(\!)\s*(?:(/=)|(?:(/)(?![/*])))'
+ captures:
+ 1: keyword.operator.logical.tsx
+ 2: keyword.operator.assignment.compound.tsx
+ 3: keyword.operator.arithmetic.tsx
+ - match: \!|&&|\|\||\?\?
scope: keyword.operator.logical.tsx
- match: \&|~|\^|\|
scope: keyword.operator.bitwise.tsx
@@ -800,9 +933,18 @@ contexts:
scope: keyword.operator.increment.tsx
- match: '%|\*|/|-|\+'
scope: keyword.operator.arithmetic.tsx
- - match: '(?<=[_$[:alnum:])\]])\s*(/)(?![/*])'
+ - match: '(?<=[_$[:alnum:])\]])\s*(?=(\/\*([^\*]|(\*[^\/]))*\*\/\s*)+(?:(/=)|(?:(/)(?![/*]))))'
+ push:
+ - match: '(?:(/=)|(?:(/)(?!\*([^\*]|(\*[^\/]))*\*\/)))'
+ captures:
+ 1: keyword.operator.assignment.compound.tsx
+ 2: keyword.operator.arithmetic.tsx
+ pop: true
+ - include: comment
+ - match: '(?<=[_$[:alnum:])\]])\s*(?:(/=)|(?:(/)(?![/*])))'
captures:
- 1: keyword.operator.arithmetic.tsx
+ 1: keyword.operator.assignment.compound.tsx
+ 2: keyword.operator.arithmetic.tsx
expressionPunctuations:
- include: punctuation-comma
- include: punctuation-accessor
@@ -810,7 +952,6 @@ contexts:
- include: jsx
- include: string
- include: regex
- - include: template
- include: comment
- include: function-expression
- include: class-expression
@@ -828,143 +969,123 @@ contexts:
- include: paren-expression
field-declaration:
- match: |-
- (?x)(?<!\()(?:(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(readonly)\s+)?(?=\s*((\b(?<!\$)0(x|X)[0-9a-fA-F][0-9a-fA-F_]*\b(?!\$))|(\b(?<!\$)0(b|B)[01][01_]*\b(?!\$))|(\b(?<!\$)0(o|O)?[0-7][0-7_]*\b(?!\$))|((?<!\$)(?:
- (?:\b[0-9][0-9_]*(\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\b)| # 1.1E+3
- (?:\b[0-9][0-9_]*(\.)[eE][+-]?[0-9][0-9_]*\b)| # 1.E+3
- (?:\B(\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\b)| # .1E+3
- (?:\b[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\b)| # 1E+3
- (?:\b[0-9][0-9_]*(\.)[0-9][0-9_]*\b)| # 1.1
- (?:\b[0-9][0-9_]*(\.)\B)| # 1.
- (?:\B(\.)[0-9][0-9_]*\b)| # .1
- (?:\b[0-9][0-9_]*\b(?!\.)) # 1
- )(?!\$))|([_$[:alpha:]][_$[:alnum:]]*)|(\'([^\'\\]|\\\'|\\)*\')|(\"([^\"\\]|\\\"|\\)*\")|(\[([^\[\]]|\[[^\[\]]*\])+\]))\s*(\?\s*)?(=|:))
+ (?x)(?<!\()(?:(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(readonly)\s+)?(?=\s*((\b(?<!\$)0(?:x|X)[0-9a-fA-F][0-9a-fA-F_]*(n)?\b(?!\$))|(\b(?<!\$)0(?:b|B)[01][01_]*(n)?\b(?!\$))|(\b(?<!\$)0(?:o|O)?[0-7][0-7_]*(n)?\b(?!\$))|((?<!\$)(?:
+ (?:\b[0-9][0-9_]*(\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*(n)?\b)| # 1.1E+3
+ (?:\b[0-9][0-9_]*(\.)[eE][+-]?[0-9][0-9_]*(n)?\b)| # 1.E+3
+ (?:\B(\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*(n)?\b)| # .1E+3
+ (?:\b[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*(n)?\b)| # 1E+3
+ (?:\b[0-9][0-9_]*(\.)[0-9][0-9_]*(n)?\b)| # 1.1
+ (?:\b[0-9][0-9_]*(\.)(n)?\B)| # 1.
+ (?:\B(\.)[0-9][0-9_]*(n)?\b)| # .1
+ (?:\b[0-9][0-9_]*(n)?\b(?!\.)) # 1
+ )(?!\$))|(\#?[_$[:alpha:]][_$[:alnum:]]*)|(\'([^\'\\]|\\.)*\')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`)|(\[([^\[\]]|\[[^\[\]]*\])+\]))\s*(?:(?:(\?)|(\!))\s*)?(=|:|;|,|\}|$))
captures:
1: storage.modifier.tsx
push:
- meta_scope: meta.field.declaration.tsx
- match: |-
- (?x)(?=\}|;|,|$|(^(?!\s*((\b(?<!\$)0(x|X)[0-9a-fA-F][0-9a-fA-F_]*\b(?!\$))|(\b(?<!\$)0(b|B)[01][01_]*\b(?!\$))|(\b(?<!\$)0(o|O)?[0-7][0-7_]*\b(?!\$))|((?<!\$)(?:
- (?:\b[0-9][0-9_]*(\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\b)| # 1.1E+3
- (?:\b[0-9][0-9_]*(\.)[eE][+-]?[0-9][0-9_]*\b)| # 1.E+3
- (?:\B(\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\b)| # .1E+3
- (?:\b[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\b)| # 1E+3
- (?:\b[0-9][0-9_]*(\.)[0-9][0-9_]*\b)| # 1.1
- (?:\b[0-9][0-9_]*(\.)\B)| # 1.
- (?:\B(\.)[0-9][0-9_]*\b)| # .1
- (?:\b[0-9][0-9_]*\b(?!\.)) # 1
- )(?!\$))|([_$[:alpha:]][_$[:alnum:]]*)|(\'([^\'\\]|\\\'|\\)*\')|(\"([^\"\\]|\\\"|\\)*\")|(\[([^\[\]]|\[[^\[\]]*\])+\]))\s*(\?\s*)?(=|:))))|(?<=\})
+ (?x)(?=\}|;|,|$|(^(?!\s*((\b(?<!\$)0(?:x|X)[0-9a-fA-F][0-9a-fA-F_]*(n)?\b(?!\$))|(\b(?<!\$)0(?:b|B)[01][01_]*(n)?\b(?!\$))|(\b(?<!\$)0(?:o|O)?[0-7][0-7_]*(n)?\b(?!\$))|((?<!\$)(?:
+ (?:\b[0-9][0-9_]*(\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*(n)?\b)| # 1.1E+3
+ (?:\b[0-9][0-9_]*(\.)[eE][+-]?[0-9][0-9_]*(n)?\b)| # 1.E+3
+ (?:\B(\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*(n)?\b)| # .1E+3
+ (?:\b[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*(n)?\b)| # 1E+3
+ (?:\b[0-9][0-9_]*(\.)[0-9][0-9_]*(n)?\b)| # 1.1
+ (?:\b[0-9][0-9_]*(\.)(n)?\B)| # 1.
+ (?:\B(\.)[0-9][0-9_]*(n)?\b)| # .1
+ (?:\b[0-9][0-9_]*(n)?\b(?!\.)) # 1
+ )(?!\$))|(\#?[_$[:alpha:]][_$[:alnum:]]*)|(\'([^\'\\]|\\.)*\')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`)|(\[([^\[\]]|\[[^\[\]]*\])+\]))\s*(?:(?:(\?)|(\!))\s*)?(=|:|;|,|$))))|(?<=\})
pop: true
- include: variable-initializer
+ - include: type-annotation
+ - include: string
+ - include: array-literal
+ - include: numeric-literal
+ - include: comment
- match: |-
- (?x)(?=((\b(?<!\$)0(x|X)[0-9a-fA-F][0-9a-fA-F_]*\b(?!\$))|(\b(?<!\$)0(b|B)[01][01_]*\b(?!\$))|(\b(?<!\$)0(o|O)?[0-7][0-7_]*\b(?!\$))|((?<!\$)(?:
- (?:\b[0-9][0-9_]*(\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\b)| # 1.1E+3
- (?:\b[0-9][0-9_]*(\.)[eE][+-]?[0-9][0-9_]*\b)| # 1.E+3
- (?:\B(\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\b)| # .1E+3
- (?:\b[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\b)| # 1E+3
- (?:\b[0-9][0-9_]*(\.)[0-9][0-9_]*\b)| # 1.1
- (?:\b[0-9][0-9_]*(\.)\B)| # 1.
- (?:\B(\.)[0-9][0-9_]*\b)| # .1
- (?:\b[0-9][0-9_]*\b(?!\.)) # 1
- )(?!\$))|([_$[:alpha:]][_$[:alnum:]]*)|(\'([^\'\\]|\\\'|\\)*\')|(\"([^\"\\]|\\\"|\\)*\")|(\[([^\[\]]|\[[^\[\]]*\])+\]))\s*(\?\s*)?(=|:))
- push:
- - match: |-
- (?x)(?=[};,=]|$|(^(?!\s*((\b(?<!\$)0(x|X)[0-9a-fA-F][0-9a-fA-F_]*\b(?!\$))|(\b(?<!\$)0(b|B)[01][01_]*\b(?!\$))|(\b(?<!\$)0(o|O)?[0-7][0-7_]*\b(?!\$))|((?<!\$)(?:
- (?:\b[0-9][0-9_]*(\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\b)| # 1.1E+3
- (?:\b[0-9][0-9_]*(\.)[eE][+-]?[0-9][0-9_]*\b)| # 1.E+3
- (?:\B(\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\b)| # .1E+3
- (?:\b[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*\b)| # 1E+3
- (?:\b[0-9][0-9_]*(\.)[0-9][0-9_]*\b)| # 1.1
- (?:\b[0-9][0-9_]*(\.)\B)| # 1.
- (?:\B(\.)[0-9][0-9_]*\b)| # .1
- (?:\b[0-9][0-9_]*\b(?!\.)) # 1
- )(?!\$))|([_$[:alpha:]][_$[:alnum:]]*)|(\'([^\'\\]|\\\'|\\)*\')|(\"([^\"\\]|\\\"|\\)*\")|(\[([^\[\]]|\[[^\[\]]*\])+\]))\s*(\?\s*)?(=|:))))|(?<=\})
- pop: true
- - include: type-annotation
- - include: string
- - include: array-literal
- - include: numeric-literal
- - include: comment
- - match: |-
- (?x)([_$[:alpha:]][_$[:alnum:]]*)(\?)?(?=(\?\s*)?\s*
- # function assignment |
- (=\s*(
- ((async\s+)?(
- (function\s*[(<*]) |
- (function\s+) |
- ([_$[:alpha:]][_$[:alnum:]]*\s*=>)
- )) |
- ((async\s*)?(
- ((<\s*$)|([\(]\s*([\{\[]\s*)?$)) |
- # sure shot arrow functions even if => is on new line
- (
- (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*>\s*)?
- [(]\s*
- (
- ([)]\s*:) | # ():
- ((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param:
- )
- ) |
- (
- [<]\s*[_$[:alpha:]][_$[:alnum:]]*\s+extends\s*[^=>] # < typeparam extends
- ) |
- # arrow function possible to detect only with => on same line
- (
- (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*>\s*)? # typeparameters
- \(\s*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()]|(\(([^\(\)]|(\([^\(\)]*\)))*\)))*)?\) # parameters
- (\s*:\s*([^<>\(\)]|\<[^<>]+\>|\([^\(\)]+\))+)? # return type
- \s*=> # arrow operator
- )
- ))
- )) |
- # typeannotation is fn type: < | () | (... | (param: | (param, | (param? | (param= | (param) =>
- (:\s*(
- (<) |
- ([(]\s*(
- ([)]) |
- (\.\.\.) |
- ([_$[:alnum:]]+\s*(
- ([:,?=])|
- ([)]\s*=>)
- ))
- ))
- )) |
- (:\s*((<\s*$)|([\(]\s*([\{\[]\s*)?$))) |
- (:\s*(=>|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(<[^<>]*>)|[^<>(),=])+=\s*(
- ((async\s+)?(
- (function\s*[(<*]) |
- (function\s+) |
- ([_$[:alpha:]][_$[:alnum:]]*\s*=>)
- )) |
- ((async\s*)?(
- ((<\s*$)|([\(]\s*([\{\[]\s*)?$)) |
- # sure shot arrow functions even if => is on new line
- (
- (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*>\s*)?
- [(]\s*
- (
- ([)]\s*:) | # ():
- ((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param:
- )
- ) |
- (
- [<]\s*[_$[:alpha:]][_$[:alnum:]]*\s+extends\s*[^=>] # < typeparam extends
- ) |
- # arrow function possible to detect only with => on same line
- (
- (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*>\s*)? # typeparameters
- \(\s*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()]|(\(([^\(\)]|(\([^\(\)]*\)))*\)))*)?\) # parameters
- (\s*:\s*([^<>\(\)]|\<[^<>]+\>|\([^\(\)]+\))+)? # return type
- \s*=> # arrow operator
- )
- ))
- )))
- captures:
- 1: meta.definition.property.tsx entity.name.function.tsx
- 2: keyword.operator.optional.tsx
- - match: "[_$[:alpha:]][_$[:alnum:]]*"
- scope: meta.definition.property.tsx variable.object.property.tsx
- - match: \?
- scope: keyword.operator.optional.tsx
+ (?x)(\#?[_$[:alpha:]][_$[:alnum:]]*)(?:(\?)|(\!))?(?=\s*\s*
+ # function assignment |
+ (=\s*(
+ ((async\s+)?(
+ (function\s*[(<*]) |
+ (function\s+) |
+ ([_$[:alpha:]][_$[:alnum:]]*\s*=>)
+ )) |
+ ((async\s*)?(
+ ((<\s*$)|([\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))) |
+ # sure shot arrow functions even if => is on new line
+ (
+ (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?
+ [(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*
+ (
+ ([)]\s*:) | # ():
+ ((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param:
+ )
+ ) |
+ (
+ [<]\s*[_$[:alpha:]][_$[:alnum:]]*\s+extends\s*[^=>] # < typeparam extends
+ ) |
+ # arrow function possible to detect only with => on same line
+ (
+