%YAML 1.2 --- # http://www.sublimetext.com/docs/3/syntax.html name: TypeScript file_extensions: - ts scope: source.ts 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.ts push: - meta_scope: comment.block.documentation.ts - match: \*/ captures: 0: punctuation.definition.comment.ts pop: true - include: docblock - match: (/\*)(?:\s*((@)internal)(?=\s|(\*/)))? captures: 1: punctuation.definition.comment.ts 2: storage.type.internaldeclaration.ts 3: punctuation.decorator.internaldeclaration.ts push: - meta_scope: comment.block.ts - match: \*/ captures: 0: punctuation.definition.comment.ts pop: true - match: '(^[ \t]+)?((//)(?:\s*((@)internal)(?=\s|$))?)' captures: 1: punctuation.whitespace.comment.leading.ts 2: comment.line.double-slash.ts 3: punctuation.definition.comment.ts 4: storage.type.internaldeclaration.ts 5: punctuation.decorator.internaldeclaration.ts push: - meta_content_scope: comment.line.double-slash.ts - match: (?=^) pop: true access-modifier: - match: '(?)' scope: meta.arrow.ts captures: 1: storage.modifier.async.ts 2: variable.parameter.ts - 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.ts push: - meta_scope: meta.arrow.ts - 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.ts push: - meta_scope: meta.arrow.ts - match: '(?<=\}|\S)(?)|((?!\{)(?=\S))' pop: true - include: decl-block - include: expression arrow-return-type: - match: (?<=\))\s*(:) captures: 1: keyword.operator.type.annotation.ts push: - meta_scope: meta.return.type.arrow.ts - 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: '(?*?\&\|\^]|[^_$[:alnum:]](?:\+\+|\-\-)|[^\+]\+|[^\-]\-))\s*(<)(?!)\s* captures: 1: meta.brace.angle.ts pop: true - include: type - match: '(?:(?<=^))\s*(<)(?=[_$[:alpha:]][_$[:alnum:]]*\s*>)' captures: 1: meta.brace.angle.ts push: - meta_scope: cast.expr.ts - match: (\>)\s* captures: 1: meta.brace.angle.ts pop: true - include: type class-declaration: - match: '(?\s*$)' captures: 1: punctuation.definition.comment.ts push: - meta_scope: comment.line.triple-slash.directive.ts - match: (?=^) pop: true - match: (<)(reference|amd-dependency|amd-module) captures: 1: punctuation.definition.tag.directive.ts 2: entity.name.tag.directive.ts push: - meta_scope: meta.tag.ts - match: /> captures: 0: punctuation.definition.tag.directive.ts pop: true - match: path|types|no-default-lib|name scope: entity.other.attribute-name.directive.ts - match: "=" scope: keyword.operator.assignment.ts - 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.ts - 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.ts 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.ts - match: "<<|>>>|>>" scope: keyword.operator.bitwise.shift.ts - match: "===|!==|==|!=" scope: keyword.operator.comparison.ts - match: <=|>=|<>|<|> scope: keyword.operator.relational.ts - match: \!|&&|\|\| scope: keyword.operator.logical.ts - match: \&|~|\^|\| scope: keyword.operator.bitwise.ts - match: \= scope: keyword.operator.assignment.ts - match: "--" scope: keyword.operator.decrement.ts - match: \+\+ scope: keyword.operator.increment.ts - match: '%|\*|/|-|\+' scope: keyword.operator.arithmetic.ts - match: '(?<=[_$[:alnum:])])\s*(/)(?![/*])' captures: 1: keyword.operator.arithmetic.ts expressionPunctuations: - include: punctuation-comma - include: punctuation-accessor expressionWithoutIdentifiers: - 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.ts entity.name.function.ts - match: "[_$[:alpha:]][_$[:alnum:]]*" scope: meta.definition.property.ts variable.object.property.ts - match: \? scope: keyword.operator.optional.ts 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.ts - 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.ts 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.ts 2: punctuation.accessor.optional.ts 3: entity.name.function.ts - match: '(?:(\.)|(\?\.(?!\s*[[:digit:]])))\s*([[:upper:]][_$[:digit:][:upper:]]*)(?![_$[:alnum:]])' captures: 1: punctuation.accessor.ts 2: punctuation.accessor.optional.ts 3: variable.other.constant.property.ts - match: '(?:(\.)|(\?\.(?!\s*[[:digit:]])))\s*([_$[:alpha:]][_$[:alnum:]]*)' captures: 1: punctuation.accessor.ts 2: punctuation.accessor.optional.ts 3: variable.other.property.ts - match: "([[:upper:]][_$[:digit:][:upper:]]*)(?![_$[:alnum:]])" scope: variable.other.constant.ts - match: "[_$[:alpha:]][_$[:alnum:]]*" scope: variable.other.readwrite.ts import-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.ts captures: 0: meta.object-literal.key.ts 1: entity.name.function.ts - match: '(?:[_$[:alpha:]][_$[:alnum:]]*)\s*(?=:)' scope: meta.object.member.ts captures: 0: meta.object-literal.key.ts - match: \.\.\. captures: 0: keyword.operator.spread.ts push: - meta_scope: meta.object.member.ts - match: '(?=,|\})' pop: true - include: expression - match: '([_$[:alpha:]][_$[:alnum:]]*)\s*(?=,|\}|$)' scope: meta.object.member.ts captures: 1: variable.other.readwrite.ts - match: '(?=[_$[:alpha:]][_$[:alnum:]]*\s*=)' push: - meta_scope: meta.object.member.ts - match: '(?=,|\}|$)' pop: true - include: expression - match: ":" captures: 0: meta.object-literal.key.ts punctuation.separator.key-value.ts push: - meta_scope: meta.object.member.ts - match: '(?=,|\})' pop: true - include: expression - include: punctuation-comma parameter-array-binding-pattern: - match: '(?:(\.\.\.)\s*)?(\[)' captures: 1: keyword.operator.rest.ts 2: punctuation.definition.binding-pattern.array.ts push: - match: '\]' captures: 0: punctuation.definition.binding-pattern.array.ts 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.ts - 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.ts 2: keyword.operator.rest.ts 3: entity.name.function.ts variable.language.this.ts 4: entity.name.function.ts 5: keyword.operator.optional.ts - match: '(?x)(?:\s*\b(public|private|protected|readonly)\s+)?(\.\.\.)?\s*(?|&&|\|\||\*\/)\s*(\/)(?![\/*])(?=(?:[^\/\\\[]|\\.|\[([^\]\\]|\\.)+\])+\/(?![\/*])[gimuy]*(?!\s*[a-zA-Z0-9_$]))' captures: 1: punctuation.definition.string.begin.ts push: - meta_scope: string.regexp.ts - match: "(/)([gimuy]*)" captures: 1: punctuation.definition.string.end.ts 2: keyword.other.ts pop: true - include: regexp - match: '(?]|=[^<]|\<\s*([_$[:alpha:]]|(\{[^\{\}]*\})|(\([^\(\)]*\))|(\[[^\[\]]*\]))([^=<>]|=[^<])*\>)*>\s*)?\() captures: 1: punctuation.accessor.ts 2: punctuation.accessor.optional.ts 3: support.constant.dom.ts 4: support.variable.property.dom.ts - match: |- (?x)(?])|((?<=[\}>\]\)]|[_$[:alpha:]])\s*(?=\{)))' pop: true - include: type - match: (:) captures: 1: keyword.operator.type.annotation.ts push: - meta_scope: meta.type.annotation.ts - match: '(?])|(?=^\s*$)|((?<=\S)(?=\s*$))|((?<=[\}>\]\)]|[_$[:alpha:]])\s*(?=\{)))' pop: true - include: type type-builtin-literals: - match: '(?) )) ) ) ) push: - meta_scope: meta.type.function.ts - match: (?<=\)) pop: true - include: function-parameters type-function-return-type: - match: (=>)(?=\s*\S) captures: 1: storage.type.function.arrow.ts push: - meta_scope: meta.type.function.return.ts - match: '(?)(?]|//|$)' pop: true - include: type-function-return-type-core - match: "=>" captures: 0: storage.type.function.arrow.ts push: - meta_scope: meta.type.function.return.ts - 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.ts 2: punctuation.accessor.ts 3: punctuation.accessor.optional.ts - match: "[_$[:alpha:]][_$[:alnum:]]*" scope: entity.name.type.ts type-object: - match: '\{' captures: 0: punctuation.definition.block.ts push: - meta_scope: meta.object.type.ts - match: '\}' captures: 0: punctuation.definition.block.ts 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.ts 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.ts push: - match: '(?<=\})' pop: true - include: type-object - match: "[&|]" captures: 0: keyword.operator.type.ts push: - match: (?=\S) pop: true - match: '(?) captures: 1: punctuation.definition.typeparameters.end.ts pop: true - include: comment - match: '(?) scope: keyword.operator.assignment.ts - include: type - include: punctuation-comma type-paren-or-function-parameters: - match: \( captures: 0: meta.brace.round.ts push: - meta_scope: meta.type.paren.cover.ts - match: \) captures: 0: meta.brace.round.ts 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.ts entity.name.function.ts push: - meta_scope: meta.var-single-variable.expr.ts - match: '(?=$|^|[;,=}]|(\s+(of|in)\s+))' pop: true - include: var-single-variable-type-annotation - match: "([[:upper:]][_$[:digit:][:upper:]]*)(?![_$[:alnum:]])" captures: 1: meta.definition.variable.ts variable.other.constant.ts push: - meta_scope: meta.var-single-variable.expr.ts - match: '(?=$|^|[;,=}]|(\s+(of|in)\s+))' pop: true - include: var-single-variable-type-annotation - match: "([_$[:alpha:]][_$[:alnum:]]*)" captures: 1: meta.definition.variable.ts variable.other.readwrite.ts push: - meta_scope: meta.var-single-variable.expr.ts - 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: (?