%YAML 1.2 --- # http://www.sublimetext.com/docs/3/syntax.html name: TypeScriptReact file_extensions: - tsx scope: source.tsx contexts: main: - include: directives - include: statements - match: \A(#!).*(?=$) scope: comment.line.shebang.ts captures: 1: punctuation.definition.comment.ts comment: - match: /\*\*(?!/) captures: 0: punctuation.definition.comment.tsx push: - meta_scope: comment.block.documentation.tsx - match: \*/ captures: 0: punctuation.definition.comment.tsx pop: true - include: docblock - match: (/\*)(?:\s*((@)internal)(?=\s|(\*/)))? captures: 1: punctuation.definition.comment.tsx 2: storage.type.internaldeclaration.tsx 3: punctuation.decorator.internaldeclaration.tsx push: - meta_scope: comment.block.tsx - match: \*/ captures: 0: punctuation.definition.comment.tsx pop: true - match: '(^[ \t]+)?((//)(?:\s*((@)internal)(?=\s|$))?)' captures: 1: punctuation.whitespace.comment.leading.tsx 2: comment.line.double-slash.tsx 3: punctuation.definition.comment.tsx 4: storage.type.internaldeclaration.tsx 5: punctuation.decorator.internaldeclaration.tsx push: - meta_content_scope: comment.line.double-slash.tsx - match: (?=^) pop: true access-modifier: - match: '(?)' scope: meta.arrow.tsx captures: 1: storage.modifier.async.tsx 2: variable.parameter.tsx - match: |- (?x) (?: (? is on new line ( [(]\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*[^()]*)?\))*)?\) # parameteres (\s*:\s*([^<>\(\)]|\<[^<>]+\>|\([^\(\)]+\))+)? # return type \s*=> # arrow operator ) ) ) captures: 1: storage.modifier.async.tsx push: - meta_scope: meta.arrow.tsx - match: '(?==>|\{|(^\s*(export|function|class|interface|let|var|const|import|enum|namespace|module|type|abstract|declare)\s+))' pop: true - include: comment - include: type-parameters - include: function-parameters - include: arrow-return-type - match: "=>" captures: 0: storage.type.function.arrow.tsx push: - meta_scope: meta.arrow.tsx - match: '(?<=\}|\S)(?)|((?!\{)(?=\S))' pop: true - include: decl-block - include: expression arrow-return-type: - match: (?<=\))\s*(:) captures: 1: keyword.operator.type.annotation.tsx push: - meta_scope: meta.return.type.arrow.tsx - match: '(?==>|\{|(^\s*(export|function|class|interface|let|var|const|import|enum|namespace|module|type|abstract|declare)\s+))' pop: true - match: '(?<=[:])(?=\s*\{)' push: - match: '(?<=\})' pop: true - include: type-object - include: type-predicate-operator - include: type binding-element: - include: comment - include: object-binding-pattern - include: array-binding-pattern - include: destructuring-variable-rest - include: variable-initializer boolean-literal: - match: '(?\s*$)' captures: 1: punctuation.definition.comment.tsx push: - meta_scope: comment.line.triple-slash.directive.tsx - match: (?=^) pop: true - match: (<)(reference|amd-dependency|amd-module) captures: 1: punctuation.definition.tag.directive.tsx 2: entity.name.tag.directive.tsx push: - meta_scope: meta.tag.tsx - match: /> captures: 0: punctuation.definition.tag.directive.tsx pop: true - match: path|types|no-default-lib|name scope: entity.other.attribute-name.directive.tsx - match: "=" scope: keyword.operator.assignment.tsx - include: string docblock: - match: |- (?x) ((@)(?:access|api)) \s+ (private|protected|public) \b captures: 1: storage.type.class.jsdoc 2: punctuation.definition.block.tag.jsdoc 3: constant.language.access-type.jsdoc - match: |- (?x) ((@)author) \s+ ( [^@\s<>*/] (?:[^@<>*/]|\*[^/])* ) (?: \s* (<) ([^>\s]+) (>) )? captures: 1: storage.type.class.jsdoc 2: punctuation.definition.block.tag.jsdoc 3: entity.name.type.instance.jsdoc 4: punctuation.definition.bracket.angle.begin.jsdoc 5: constant.other.email.link.underline.jsdoc 6: punctuation.definition.bracket.angle.end.jsdoc - match: |- (?x) ((@)borrows) \s+ ((?:[^@\s*/]|\*[^/])+) # \s+ (as) \s+ # as ((?:[^@\s*/]|\*[^/])+) # captures: 1: storage.type.class.jsdoc 2: punctuation.definition.block.tag.jsdoc 3: entity.name.type.instance.jsdoc 4: keyword.operator.control.jsdoc 5: entity.name.type.instance.jsdoc - match: ((@)example)\s+ captures: 1: storage.type.class.jsdoc 2: punctuation.definition.block.tag.jsdoc push: - meta_scope: meta.example.jsdoc - match: (?=@|\*/) pop: true - match: ^\s\*\s+ - match: \G(<)caption(>) captures: 0: entity.name.tag.inline.jsdoc 1: punctuation.definition.bracket.angle.begin.jsdoc 2: punctuation.definition.bracket.angle.end.jsdoc push: - meta_content_scope: constant.other.description.jsdoc - match: ()|(?=\*/) captures: 0: entity.name.tag.inline.jsdoc 1: punctuation.definition.bracket.angle.begin.jsdoc 2: punctuation.definition.bracket.angle.end.jsdoc pop: true - match: '[^\s@*](?:[^*]|\*[^/])*' captures: 0: source.embedded.tsx - match: (?x) ((@)kind) \s+ (class|constant|event|external|file|function|member|mixin|module|namespace|typedef) \b captures: 1: storage.type.class.jsdoc 2: punctuation.definition.block.tag.jsdoc 3: constant.language.symbol-type.jsdoc - match: |- (?x) ((@)see) \s+ (?: # URL ( (?=https?://) (?:[^\s*]|\*[^/])+ ) | # JSDoc namepath ( (?! # Avoid matching bare URIs (also acceptable as links) https?:// | # Avoid matching {@inline tags}; we match those below (?:\[[^\[\]]*\])? # Possible description [preceding]{@tag} {@(?:link|linkcode|linkplain|tutorial)\b ) # Matched namepath (?:[^@\s*/]|\*[^/])+ ) ) captures: 1: storage.type.class.jsdoc 2: punctuation.definition.block.tag.jsdoc 3: variable.other.link.underline.jsdoc 4: entity.name.type.instance.jsdoc - match: |- (?x) ((@)template) \s+ # One or more valid identifiers ( [A-Za-z_$] # First character: non-numeric word character [\w$.\[\]]* # Rest of identifier (?: # Possible list of additional identifiers \s* , \s* [A-Za-z_$] [\w$.\[\]]* )* ) captures: 1: storage.type.class.jsdoc 2: punctuation.definition.block.tag.jsdoc 3: variable.other.jsdoc - match: |- (?x) ( (@) (?:arg|argument|const|constant|member|namespace|param|var) ) \s+ ( [A-Za-z_$] [\w$.\[\]]* ) captures: 1: storage.type.class.jsdoc 2: punctuation.definition.block.tag.jsdoc 3: variable.other.jsdoc - match: '((@)typedef)\s+(?={)' captures: 1: storage.type.class.jsdoc 2: punctuation.definition.block.tag.jsdoc push: - match: '(?=\s|\*/|[^{}\[\]A-Za-z_$])' pop: true - include: jsdoctype - match: '(?:[^@\s*/]|\*[^/])+' scope: entity.name.type.instance.jsdoc - match: '((@)(?:arg|argument|const|constant|member|namespace|param|prop|property|var))\s+(?={)' captures: 1: storage.type.class.jsdoc 2: punctuation.definition.block.tag.jsdoc push: - match: '(?=\s|\*/|[^{}\[\]A-Za-z_$])' pop: true - include: jsdoctype - match: '([A-Za-z_$][\w$.\[\]]*)' scope: variable.other.jsdoc - match: |- (?x) (\[)\s* [\w$]+ (?: (?:\[\])? # Foo[ ].bar properties within an array \. # Foo.Bar namespaced parameter [\w$]+ )* (?: \s* (=) # [foo=bar] Default parameter value \s* ( # The inner regexes are to stop the match early at */ and to not stop at escaped quotes (?> "(?:(?:\*(?!/))|(?:\\(?!"))|[^*\\])*?" | # [foo="bar"] Double-quoted '(?:(?:\*(?!/))|(?:\\(?!'))|[^*\\])*?' | # [foo='bar'] Single-quoted \[ (?:(?:\*(?!/))|[^*])*? \] | # [foo=[1,2]] Array literal (?:(?:\*(?!/))|\s(?!\s*\])|\[.*?(?:\]|(?=\*/))|[^*\s\[\]])* # Everything else )* ) )? \s*(?:(\])((?:[^*\s]|\*[^\s/])+)?|(?=\*/)) scope: variable.other.jsdoc captures: 1: punctuation.definition.optional-value.begin.bracket.square.jsdoc 2: keyword.operator.assignment.jsdoc 3: source.embedded.tsx 4: punctuation.definition.optional-value.end.bracket.square.jsdoc 5: invalid.illegal.syntax.jsdoc - match: |- (?x) ( (@) (?:define|enum|exception|export|extends|lends|implements|modifies |namespace|private|protected|returns?|suppress|this|throws|type |yields?) ) \s+(?={) captures: 1: storage.type.class.jsdoc 2: punctuation.definition.block.tag.jsdoc push: - match: '(?=\s|\*/|[^{}\[\]A-Za-z_$])' pop: true - include: jsdoctype - match: |- (?x) ( (@) (?:alias|augments|callback|constructs|emits|event|fires|exports? |extends|external|function|func|host|lends|listens|interface|memberof!? |method|module|mixes|mixin|name|requires|see|this|typedef|uses) ) \s+ ( (?: [^{}@\s*] | \*[^/] )+ ) captures: 1: storage.type.class.jsdoc 2: punctuation.definition.block.tag.jsdoc 3: entity.name.type.instance.jsdoc - match: '((@)(?:default(?:value)?|license|version))\s+(([''''"]))' captures: 1: storage.type.class.jsdoc 2: punctuation.definition.block.tag.jsdoc 3: variable.other.jsdoc 4: punctuation.definition.string.begin.jsdoc push: - meta_content_scope: variable.other.jsdoc - match: (\3)|(?=$|\*/) captures: 0: variable.other.jsdoc 1: punctuation.definition.string.end.jsdoc pop: true - match: '((@)(?:default(?:value)?|license|tutorial|variation|version))\s+([^\s*]+)' captures: 1: storage.type.class.jsdoc 2: punctuation.definition.block.tag.jsdoc 3: variable.other.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' scope: storage.type.class.jsdoc captures: 1: punctuation.definition.block.tag.jsdoc - include: inline-tags enum-declaration: - match: '(?>=|>>>=|\|= scope: keyword.operator.assignment.compound.bitwise.tsx - match: "<<|>>>|>>" scope: keyword.operator.bitwise.shift.tsx - match: "===|!==|==|!=" scope: keyword.operator.comparison.tsx - match: <=|>=|<>|<|> scope: keyword.operator.relational.tsx - match: \!|&&|\|\| scope: keyword.operator.logical.tsx - match: \&|~|\^|\| scope: keyword.operator.bitwise.tsx - match: \= scope: keyword.operator.assignment.tsx - match: "--" scope: keyword.operator.decrement.tsx - match: \+\+ scope: keyword.operator.increment.tsx - match: '%|\*|/|-|\+' scope: keyword.operator.arithmetic.tsx - match: '(?<=[_$[:alnum:])])\s*(/)(?![/*])' captures: 1: keyword.operator.arithmetic.tsx expressionPunctuations: - include: punctuation-comma - include: punctuation-accessor expressionWithoutIdentifiers: - include: jsx - include: string - include: regex - include: template - include: comment - include: function-expression - include: class-expression - include: arrow-function - include: cast - include: ternary-expression - include: new-expr - include: object-literal - include: expression-operators - include: function-call - include: literal - include: support-objects - include: paren-expression field-declaration: - match: '(?) )) | ((async\s*)?( # sure shot arrow functions even if => is on new line ( [(]\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*[^()]*)?\))*)?\) # parameteres (\s*:\s*([^<>\(\)]|\<[^<>]+\>|\([^\(\)]+\))+)? # return type \s*=> # arrow operator ) )) )) | # typeannotation is fn type: < | () | (... | (param: | (param, | (param? | (param= | (param) => (:\s*( (<) | ([(]\s*( ([)]) | (\.\.\.) | ([_$[:alnum:]]+\s*( ([:,?=])| ([)]\s*=>) )) )) ))) scope: meta.definition.property.tsx entity.name.function.tsx - match: "[_$[:alpha:]][_$[:alnum:]]*" scope: meta.definition.property.tsx variable.object.property.tsx - match: \? scope: keyword.operator.optional.tsx for-loop: - match: '(?\(]|(\([^\(\)]*\))|\<\s*(([_$[:alpha:]]|(\{[^\{\}]*\})|(\([^\(\)]*\))|(\[[^\[\]]*\]))|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))([^<>\(]|(\([^\(\)]*\)))*\>)*>\s*)?\()' push: - match: '(?<=\))(?!(([_$[:alpha:]][_$[:alnum:]]*\s*\??\.\s*)*|(\??\.\s*)?)([_$[:alpha:]][_$[:alnum:]]*)\s*(\?\.\s*)?(<\s*(([_$[:alpha:]]|(\{[^\{\}]*\})|(\([^\(\)]*\))|(\[[^\[\]]*\]))|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))([^<>\(]|(\([^\(\)]*\))|\<\s*(([_$[:alpha:]]|(\{[^\{\}]*\})|(\([^\(\)]*\))|(\[[^\[\]]*\]))|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))([^<>\(]|(\([^\(\)]*\)))*\>)*>\s*)?\()' pop: true - match: '(?=(([_$[:alpha:]][_$[:alnum:]]*\s*\??\.\s*)*|(\??\.\s*)?)([_$[:alpha:]][_$[:alnum:]]*))' push: - meta_scope: meta.function-call.tsx - match: '(?=\s*(\?\.\s*)?(<\s*(([_$[:alpha:]]|(\{[^\{\}]*\})|(\([^\(\)]*\))|(\[[^\[\]]*\]))|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))([^<>\(]|(\([^\(\)]*\))|\<\s*(([_$[:alpha:]]|(\{[^\{\}]*\})|(\([^\(\)]*\))|(\[[^\[\]]*\]))|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))([^<>\(]|(\([^\(\)]*\)))*\>)*>\s*)?\()' pop: true - include: literal - include: support-objects - include: object-identifiers - include: punctuation-accessor - match: '(?:(? captures: 0: punctuation.definition.typeparameters.end.tsx pop: true - include: type - include: punctuation-comma - include: paren-expression function-declaration: - match: '(?) )) | ((async\s*)?( # sure shot arrow functions even if => is on new line ( [(]\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*[^()]*)?\))*)?\) # parameteres (\s*:\s*([^<>\(\)]|\<[^<>]+\>|\([^\(\)]+\))+)? # return type \s*=> # arrow operator ) )) )) captures: 1: punctuation.accessor.tsx 2: punctuation.accessor.optional.tsx 3: entity.name.function.tsx - match: '(?:(\.)|(\?\.(?!\s*[[:digit:]])))\s*([[:upper:]][_$[:digit:][:upper:]]*)(?![_$[:alnum:]])' captures: 1: punctuation.accessor.tsx 2: punctuation.accessor.optional.tsx 3: variable.other.constant.property.tsx - match: '(?:(\.)|(\?\.(?!\s*[[:digit:]])))\s*([_$[:alpha:]][_$[:alnum:]]*)' captures: 1: punctuation.accessor.tsx 2: punctuation.accessor.optional.tsx 3: variable.other.property.tsx - match: "([[:upper:]][_$[:digit:][:upper:]]*)(?![_$[:alnum:]])" scope: variable.other.constant.tsx - match: "[_$[:alpha:]][_$[:alnum:]]*" scope: variable.other.readwrite.tsx import-declaration: - match: '(?)) push: - match: '(/>)|(?:())' captures: 0: meta.tag.tsx 1: punctuation.definition.tag.end.tsx 2: punctuation.definition.tag.begin.tsx 3: entity.name.tag.tsx 4: support.class.component.tsx 5: punctuation.definition.tag.end.tsx pop: true - include: jsx-tag jsx-children: - include: jsx-tag-without-attributes - include: jsx-child-tag - include: jsx-evaluated-code - include: jsx-entities jsx-entities: - match: "(&)([a-zA-Z0-9]+|#[0-9]+|#x[0-9a-fA-F]+)(;)" scope: constant.character.entity.tsx captures: 1: punctuation.definition.entity.tsx 3: punctuation.definition.entity.tsx - match: "&" scope: invalid.illegal.bad-ampersand.tsx jsx-evaluated-code: - match: '\{' captures: 0: punctuation.section.embedded.begin.tsx push: - meta_scope: meta.embedded.expression.tsx - match: '\}' captures: 0: punctuation.section.embedded.end.tsx pop: true - include: expression jsx-string-double-quoted: - match: '"' captures: 0: punctuation.definition.string.begin.tsx push: - meta_scope: string.quoted.double.tsx - match: '"' captures: 0: punctuation.definition.string.end.tsx pop: true - include: jsx-entities jsx-string-single-quoted: - match: "'" captures: 0: punctuation.definition.string.begin.tsx push: - meta_scope: string.quoted.single.tsx - match: "'" captures: 0: punctuation.definition.string.end.tsx pop: true - include: jsx-entities jsx-tag: - match: |- (?x) (?=(<)\s* ([_$a-zA-Z][-$\w.]*(?)) push: - meta_scope: meta.tag.tsx - match: '(?=(/>)|(?:()))' pop: true - match: |- (?x) (<)\s* ((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\w.]*))(?) captures: 1: punctuation.definition.tag.begin.tsx 2: entity.name.tag.tsx 3: support.class.component.tsx push: - meta_content_scope: meta.tag.attributes.tsx - match: "(?=[/]?>)" pop: true - include: comment - include: jsx-tag-attributes - include: jsx-tag-attributes-illegal - match: (>) captures: 1: punctuation.definition.tag.end.tsx push: - meta_content_scope: meta.jsx.children.tsx - match: (?=|/\*|//) captures: 1: entity.other.attribute-name.tsx jsx-tag-attributes: - include: jsx-tag-attribute-name - include: jsx-tag-attribute-assignment - include: jsx-string-double-quoted - include: jsx-string-single-quoted - include: jsx-evaluated-code jsx-tag-attributes-illegal: - match: \S+ scope: invalid.illegal.attribute.tsx jsx-tag-in-expression: - match: |- (?x) (?<=[({\[,?=>:*]|&&|\|\||\?|\Wreturn|^return|\Wdefault|^)\s* (?!<\s*[_$[:alpha:]][_$[:alnum:]]*((\s+extends\s+[^=>])|,)) # look ahead is not type parameter of arrow (?=(<)\s* ([_$a-zA-Z][-$\w.]*(?)) push: - match: '(/>)|(?:())' captures: 0: meta.tag.tsx 1: punctuation.definition.tag.end.tsx 2: punctuation.definition.tag.begin.tsx 3: entity.name.tag.tsx 4: support.class.component.tsx 5: punctuation.definition.tag.end.tsx pop: true - include: jsx-tag jsx-tag-without-attributes: - match: '(<)\s*((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\w.]*))(?)' captures: 1: punctuation.definition.tag.begin.tsx 2: entity.name.tag.tsx 3: support.class.component.tsx 4: punctuation.definition.tag.end.tsx push: - meta_scope: meta.tag.without-attributes.tsx - meta_content_scope: meta.jsx.children.tsx - match: '()' captures: 1: punctuation.definition.tag.begin.tsx 2: entity.name.tag.tsx 3: support.class.component.tsx 4: punctuation.definition.tag.end.tsx pop: true - include: jsx-children jsx-tag-without-attributes-in-expression: - match: |- (?x) (?<=[({\[,?=>:*]|&&|\|\||\?|\Wreturn|^return|\Wdefault|^)\s* (?=(<)\s*((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\w.]*))(?)) push: - match: '(?!\s*(<)\s*((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\w.]*))(?))' pop: true - include: jsx-tag-without-attributes literal: - include: numeric-literal - include: boolean-literal - include: null-literal - include: undefined-literal - include: numericConstant-literal - include: array-literal - include: this-literal - include: super-literal method-declaration: - match: '(?) )) | ((async\s*)?( # sure shot arrow functions even if => is on new line ( [(]\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*[^()]*)?\))*)?\) # parameteres (\s*:\s*([^<>\(\)]|\<[^<>]+\>|\([^\(\)]+\))+)? # return type \s*=> # arrow operator ) )) ))) scope: meta.object.member.tsx captures: 0: meta.object-literal.key.tsx 1: entity.name.function.tsx - match: '(?:[_$[:alpha:]][_$[:alnum:]]*)\s*(?=:)' scope: meta.object.member.tsx captures: 0: meta.object-literal.key.tsx - match: \.\.\. captures: 0: keyword.operator.spread.tsx push: - meta_scope: meta.object.member.tsx - match: '(?=,|\})' pop: true - include: expression - match: '([_$[:alpha:]][_$[:alnum:]]*)\s*(?=,|\}|$)' scope: meta.object.member.tsx captures: 1: variable.other.readwrite.tsx - match: '(?=[_$[:alpha:]][_$[:alnum:]]*\s*=)' push: - meta_scope: meta.object.member.tsx - match: '(?=,|\}|$)' pop: true - include: expression - match: ":" captures: 0: meta.object-literal.key.tsx punctuation.separator.key-value.tsx push: - meta_scope: meta.object.member.tsx - match: '(?=,|\})' pop: true - include: expression - include: punctuation-comma parameter-array-binding-pattern: - match: '(?:(\.\.\.)\s*)?(\[)' captures: 1: keyword.operator.rest.tsx 2: punctuation.definition.binding-pattern.array.tsx push: - match: '\]' captures: 0: punctuation.definition.binding-pattern.array.tsx pop: true - include: parameter-binding-element - include: punctuation-comma parameter-binding-element: - include: comment - include: parameter-object-binding-pattern - include: parameter-array-binding-pattern - include: destructuring-parameter-rest - include: variable-initializer parameter-name: - match: \s*\b(public|protected|private|readonly)(?=\s+(public|protected|private|readonly)\s+) captures: 1: storage.modifier.tsx - match: |- (?x)(?:\s*\b(public|private|protected|readonly)\s+)?(\.\.\.)?\s*(?) )) | ((async\s*)?( # sure shot arrow functions even if => is on new line ( [(]\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*[^()]*)?\))*)?\) # parameteres (\s*:\s*([^<>\(\)]|\<[^<>]+\>|\([^\(\)]+\))+)? # return type \s*=> # arrow operator ) )) )) | # typeannotation is fn type: < | () | (... | (param: | (param, | (param? | (param= | (param) => (:\s*( (<) | ([(]\s*( ([)]) | (\.\.\.) | ([_$[:alnum:]]+\s*( ([:,?=])| ([)]\s*=>) )) )) ))) 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)(?:\s*\b(public|private|protected|readonly)\s+)?(\.\.\.)?\s*(?|&&|\|\||\*\/)\s*(\/)(?![\/*])(?=(?:[^\/\\\[]|\\.|\[([^\]\\]|\\.)+\])+\/(?![\/*])[gimuy]*(?!\s*[a-zA-Z0-9_$]))' captures: 1: punctuation.definition.string.begin.tsx push: - meta_scope: string.regexp.tsx - match: "(/)([gimuy]*)" captures: 1: punctuation.definition.string.end.tsx 2: keyword.other.tsx pop: true - include: regexp - match: '(?]|=[^<]|\<\s*([_$[:alpha:]]|(\{[^\{\}]*\})|(\([^\(\)]*\))|(\[[^\[\]]*\]))([^=<>]|=[^<])*\>)*>\s*)?\() captures: 1: punctuation.accessor.tsx 2: punctuation.accessor.optional.tsx 3: support.constant.dom.tsx 4: support.variable.property.dom.tsx - match: |- (?x)(?])|((?<=[\}>\]\)]|[_$[:alpha:]])\s*(?=\{)))' pop: true - include: type - match: (:) captures: 1: keyword.operator.type.annotation.tsx push: - meta_scope: meta.type.annotation.tsx - match: '(?])|(?=^\s*$)|((?<=\S)(?=\s*$))|((?<=[\}>\]\)]|[_$[:alpha:]])\s*(?=\{)))' pop: true - include: type type-builtin-literals: - match: '(?) )) ) ) ) push: - meta_scope: meta.type.function.tsx - match: (?<=\)) pop: true - include: function-parameters type-function-return-type: - match: (=>)(?=\s*\S) captures: 1: storage.type.function.arrow.tsx push: - meta_scope: meta.type.function.return.tsx - match: '(?)(?]|//|$)' pop: true - include: type-function-return-type-core - match: "=>" captures: 0: storage.type.function.arrow.tsx push: - meta_scope: meta.type.function.return.tsx - match: '(?)(?]|//|^\s*$)|((?<=\S)(?=\s*$)))' pop: true - include: type-function-return-type-core type-function-return-type-core: - include: comment - match: '(?<==>)(?=\s*\{)' push: - match: '(?<=\})' pop: true - include: type-object - include: type-predicate-operator - include: type type-name: - match: '([_$[:alpha:]][_$[:alnum:]]*)\s*(?:(\.)|(\?\.(?!\s*[[:digit:]])))' captures: 1: entity.name.type.module.tsx 2: punctuation.accessor.tsx 3: punctuation.accessor.optional.tsx - match: "[_$[:alpha:]][_$[:alnum:]]*" scope: entity.name.type.tsx type-object: - match: '\{' captures: 0: punctuation.definition.block.tsx push: - meta_scope: meta.object.type.tsx - match: '\}' captures: 0: punctuation.definition.block.tsx pop: true - include: comment - include: method-declaration - include: indexer-declaration - include: indexer-mapped-type-declaration - include: field-declaration - include: type-annotation - match: \.\.\. captures: 0: keyword.operator.spread.tsx push: - match: '(?=\}|;|,|$)|(?<=\})' pop: true - include: type - include: punctuation-comma - include: punctuation-semicolon - include: type type-operators: - include: typeof-operator - match: '([&|])(?=\s*\{)' captures: 0: keyword.operator.type.tsx push: - match: '(?<=\})' pop: true - include: type-object - match: "[&|]" captures: 0: keyword.operator.type.tsx push: - match: (?=\S) pop: true - match: '(?) captures: 1: punctuation.definition.typeparameters.end.tsx pop: true - include: comment - match: '(?) scope: keyword.operator.assignment.tsx - include: type - include: punctuation-comma type-paren-or-function-parameters: - match: \( captures: 0: meta.brace.round.tsx push: - meta_scope: meta.type.paren.cover.tsx - match: \) captures: 0: meta.brace.round.tsx pop: true - include: type - include: function-parameters type-predicate-operator: - match: '(?) )) | ((async\s*)?( # sure shot arrow functions even if => is on new line ( [(]\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*[^()]*)?\))*)?\) # parameteres (\s*:\s*([^<>\(\)]|\<[^<>]+\>|\([^\(\)]+\))+)? # return type \s*=> # arrow operator ) )) )) | # typeannotation is fn type: < | () | (... | (param: | (param, | (param? | (param= | (param) => (:\s*( (<) | ([(]\s*( ([)]) | (\.\.\.) | ([_$[:alnum:]]+\s*( ([:,?=])| ([)]\s*=>) )) )) ))) captures: 1: meta.definition.variable.tsx entity.name.function.tsx push: - meta_scope: meta.var-single-variable.expr.tsx - match: '(?=$|^|[;,=}]|(\s+(of|in)\s+))' pop: true - include: var-single-variable-type-annotation - match: "([[:upper:]][_$[:digit:][:upper:]]*)(?![_$[:alnum:]])" captures: 1: meta.definition.variable.tsx variable.other.constant.tsx push: - meta_scope: meta.var-single-variable.expr.tsx - match: '(?=$|^|[;,=}]|(\s+(of|in)\s+))' pop: true - include: var-single-variable-type-annotation - match: "([_$[:alpha:]][_$[:alnum:]]*)" captures: 1: meta.definition.variable.tsx variable.other.readwrite.tsx push: - meta_scope: meta.var-single-variable.expr.tsx - match: '(?=$|^|[;,=}]|(\s+(of|in)\s+))' pop: true - include: var-single-variable-type-annotation var-single-variable-type-annotation: - include: type-annotation - include: string - include: comment variable-initializer: - match: (?