%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: /\* captures: 0: punctuation.definition.comment.ts push: - meta_scope: comment.block.ts - match: \*/ captures: 0: punctuation.definition.comment.ts pop: true - match: '(^[ \t]+)?(?=//)' captures: 1: punctuation.whitespace.comment.leading.ts push: - match: (?=$) pop: true - match: // captures: 0: punctuation.definition.comment.ts push: - meta_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*:) | # (): ([_$[:alpha:]][_$[:alnum:]]*\s*:) | # [(]param: (\.\.\.) # [(]... ) ) | ( [<]\s*[_$[:alpha:]][_$[:alnum:]]*\s+extends\s*[^=>] # < typeparam extends ) | # arrow function possible to detect only with => on same line ( (<([^<>]|\<[^<>]+\>)+>\s*)? # typeparameters \(([^()]|\([^()]*\))*\) # parameteres (\s*:\s*(.)*)? # return type \s*=> # arrow operator ) ) ) captures: 1: storage.modifier.async.ts push: - meta_scope: meta.arrow.ts - match: '(?==>|\{)' 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))' 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: '(?==>|\{)' pop: true - match: '(?<=:)\s*(\{)' captures: 1: punctuation.definition.block.ts push: - meta_scope: meta.object.type.ts - match: '\}' captures: 0: punctuation.definition.block.ts pop: true - include: type-object-members - 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: 0: meta.brace.angle.ts pop: true - include: type class-or-interface-body: - match: '\{' captures: 0: punctuation.definition.block.ts push: - match: '\}' captures: 0: punctuation.definition.block.ts pop: true - include: string - include: comment - include: decorator - include: method-declaration - include: indexer-declaration - include: field-declaration - include: type-annotation - include: variable-initializer - include: access-modifier - include: property-accessor - include: after-operator-block - include: decl-block - include: expression - include: punctuation-comma - include: punctuation-semicolon class-or-interface-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)(? # {Array} or {Object} type application (optional .) ) (?: [\.|~] # {Foo.bar} namespaced, {string|number} multiple, {Foo~bar} class-specific callback [a-zA-Z_$]+ (?: (?: [\w$]* (?:\[\])? # {(string|number[])} type application, a string or an array of numbers ) | \.?<[\w$]+(?:,\s+[\w$]+)*> # {Array} or {Object} type application (optional .) ) )* \) | [a-zA-Z_$]+ (?: (?: [\w$]* (?:\[\])? # {(string|number[])} type application, a string or an array of numbers ) | \.?<[\w$]+(?:,\s+[\w$]+)*> # {Array} or {Object} type application (optional .) ) (?: [\.|~] # {Foo.bar} namespaced, {string|number} multiple, {Foo~bar} class-specific callback [a-zA-Z_$]+ (?: [\w$]* | \.?<[\w$]+(?:,\s+[\w$]+)*> # {Array} or {Object} type application (optional .) ) )* ) ) # Check for suffix (?:\[\])? # {string[]} type application, an array of strings =? # {string=} optional parameter ) )}) \s+ ( \[ # [foo] optional parameter \s* (?: [a-zA-Z_$][\w$]* (?: (?:\[\])? # Foo[].bar properties within an array \. # Foo.Bar namespaced parameter [a-zA-Z_$][\w$]* )* (?: \s* = # [foo=bar] Default parameter value \s* [\w$\s]* )? ) \s* \] | (?: [a-zA-Z_$][\w$]* (?: (?:\[\])? # Foo[].bar properties within an array \. # Foo.Bar namespaced parameter [a-zA-Z_$][\w$]* )* )? ) \s+ (?:-\s+)? # optional hyphen before the description ((?:(?!\*\/).)*) # The type description captures: 0: other.meta.jsdoc 1: entity.name.type.instance.jsdoc 2: variable.other.jsdoc 3: other.description.jsdoc - match: |- (?x) ({(?: \* | # {*} any type \? | # {?} unknown type (?: (?: # Check for a prefix \? | # {?string} nullable type ! | # {!string} non-nullable type \.{3} # {...string} variable number of parameters )? (?: (?: function # {function(string, number)} function type \s* \( \s* (?: [a-zA-Z_$][\w$]* (?: \s*,\s* [a-zA-Z_$][\w$]* )* )? \s* \) (?: # {function(): string} function return type \s*:\s* [a-zA-Z_$][\w$]* )? )? | (?: \( # Opening bracket of multiple types with parenthesis {(string|number)} [a-zA-Z_$]+ (?: [\w$]* | \.?<[\w$]+(?:,\s+[\w$]+)*> # {Array} or {Object} type application (optional .) ) (?: [\.|~] # {Foo.bar} namespaced, {string|number} multiple, {Foo~bar} class-specific callback [a-zA-Z_$]+ (?: [\w$]* | \.?<[\w$]+(?:,\s+[\w$]+)*> # {Array} or {Object} type application (optional .) ) )* \) | [a-zA-Z_$]+ (?: [\w$]* | \.?<[\w$]+(?:,\s+[\w$]+)*> # {Array} or {Object} type application (optional .) ) (?: [\.|~] # {Foo.bar} namespaced, {string|number} multiple, {Foo~bar} class-specific callback [a-zA-Z_$]+ (?: [\w$]* | \.?<[\w$]+(?:,\s+[\w$]+)*> # {Array} or {Object} type application (optional .) ) )* ) ) # Check for suffix (?:\[\])? # {string[]} type application, an array of strings =? # {string=} optional parameter ) )}) \s+ (?:-\s+)? # optional hyphen before the description ((?:(?!\*\/).)*) # The type description captures: 0: other.meta.jsdoc 1: entity.name.type.instance.jsdoc 2: other.description.jsdoc 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 field-declaration: - match: '(?) | ([(]\s*(([)]\s*:)|([_$[:alpha:]][_$[:alnum:]]*\s*:)|(\.\.\.) )) | ([<]\s*[_$[:alpha:]][_$[:alnum:]]*((\s+extends\s*[^=>])|(\s*[,]))) | ((<([^<>]|\<[^<>]+\>)+>\s*)?\(([^()]|\([^()]*\))*\)(\s*:\s*(.)*)?\s*=>)) ) | (:\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*)?\()' push: - match: '(?<=\))(?!(([_$[:alpha:]][_$[:alnum:]]*\s*\.\s*)*|(\.\s*)?)([_$[:alpha:]][_$[:alnum:]]*)\s*(<([^<>]|\<[^<>]+\>)+>\s*)?\()' pop: true - include: literal - include: support-objects - include: object-identifiers - include: punctuation-accessor - match: "([_$[:alpha:]][_$[:alnum:]]*)" scope: entity.name.function.ts - include: comment - match: \< captures: 0: punctuation.definition.typeparameters.begin.ts push: - meta_scope: meta.type.parameters.ts - match: \> captures: 0: punctuation.definition.typeparameters.end.ts pop: true - include: type - include: punctuation-comma - include: paren-expression function-declaration: - match: '(?)| ([(]\s*(([)]\s*:)|([_$[:alpha:]][_$[:alnum:]]*\s*:)|(\.\.\.) )) | ([<]\s*[_$[:alpha:]][_$[:alnum:]]*((\s+extends\s*[^=>])|(\s*[,]))) | ((<([^<>]|\<[^<>]+\>)+>\s*)?\(([^()]|\([^()]*\))*\)(\s*:\s*(.)*)?\s*=>))) captures: 1: punctuation.accessor.ts 2: entity.name.function.ts - match: '(\.)\s*([[:upper:]][_$[:digit:][:upper:]]*)(?![_$[:alnum:]])' captures: 1: punctuation.accessor.ts 2: variable.other.constant.property.ts - match: '(\.)\s*([_$[:alpha:]][_$[:alnum:]]*)' captures: 1: punctuation.accessor.ts 2: 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: (?)| ([(]\s*(([)]\s*:)|([_$[:alpha:]][_$[:alnum:]]*\s*:)|(\.\.\.) )) | ([<]\s*[_$[:alpha:]][_$[:alnum:]]*((\s+extends\s*[^=>])|(\s*[,]))) | ((<([^<>]|\<[^<>]+\>)+>\s*)?\(([^()]|\([^()]*\))*\)(\s*:\s*(.)*)?\s*=>)))) captures: 0: meta.object-literal.key.ts 1: entity.name.function.ts 2: punctuation.separator.key-value.ts push: - meta_scope: meta.object.member.ts - match: '(?=,|\})' pop: true - include: expression - match: '(?:[_$[:alpha:]][_$[:alnum:]]*)\s*(:)' captures: 0: meta.object-literal.key.ts 1: punctuation.separator.key-value.ts push: - meta_scope: meta.object.member.ts - match: '(?=,|\})' pop: true - include: expression - 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 - 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*(?) | ([(]\s*(([)]\s*:)|([_$[:alpha:]][_$[:alnum:]]*\s*:)|(\.\.\.) )) | ([<]\s*[_$[:alpha:]][_$[:alnum:]]*((\s+extends\s*[^=>])|(\s*[,]))) | ((<([^<>]|\<[^<>]+\>)+>\s*)?\(([^()]|\([^()]*\))*\)(\s*:\s*(.)*)?\s*=>)) ) | (:\s*( (<) | ([(]\s*( ([)]) | (\.\.\.) | ([_$[:alnum:]]+\s*( ([:,?=])| ([)]\s*=>) )) ))) ) ) captures: 1: storage.modifier.ts 2: keyword.operator.rest.ts 3: entity.name.function.ts 4: keyword.operator.optional.ts - match: '(?:\s*\b(public|private|protected|readonly)\s+)?(\.\.\.)?\s*(?|&&|\|\||\*\/)\s*(/)(?![/*])(?=(?:[^/\\\[]|\\.|\[([^\]\\]|\\.)+\])+/(?![/*])[gimy]*(?!\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*)?\() captures: 1: punctuation.accessor.ts 2: support.constant.dom.ts 3: support.variable.property.dom.ts - match: |- (?x)(?])|(?<=[\}>\]\)]|[_$[:alpha:]])\s*(?=\{)' pop: true - include: comment - include: type type-builtin-literals: - match: (?) )) ) ) ) push: - meta_scope: meta.type.function.ts - match: (?<=\)) pop: true - include: function-parameters type-function-return-type: - match: "=>" captures: 0: storage.type.function.arrow.ts push: - meta_scope: meta.type.function.return.ts - match: '(?)(?=[,\]\)\{\}=;>]|//|$)' pop: true - include: comment - match: '(?<==>)\s*(\{)' captures: 1: punctuation.definition.block.ts push: - meta_scope: meta.object.type.ts - match: '\}' captures: 0: punctuation.definition.block.ts pop: true - include: type-object-members - include: type-predicate-operator - include: type type-name: - match: '([_$[:alpha:]][_$[:alnum:]]*)\s*(\.)' captures: 1: entity.name.type.module.ts 2: punctuation.accessor.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: type-object-members type-object-members: - 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: "[&|]" scope: keyword.operator.type.ts - 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: (?) | ([(]\s*(([)]\s*:)|([_$[:alpha:]][_$[:alnum:]]*\s*:)|(\.\.\.) )) | ([<]\s*[_$[:alpha:]][_$[:alnum:]]*((\s+extends\s*[^=>])|(\s*[,]))) | ((<([^<>]|\<[^<>]+\>)+>\s*)?\(([^()]|\([^()]*\))*\)(\s*:\s*(.)*)?\s*=>)) ) | (:\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: (?