You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2367 lines
102KB

  1. %YAML 1.2
  2. ---
  3. # http://www.sublimetext.com/docs/3/syntax.html
  4. name: TypeScript
  5. file_extensions:
  6. - ts
  7. scope: source.ts
  8. contexts:
  9. main:
  10. - include: directives
  11. - include: statements
  12. - match: \A(#!).*(?=$)
  13. scope: comment.line.shebang.ts
  14. captures:
  15. 1: punctuation.definition.comment.ts
  16. comment:
  17. - match: /\*\*(?!/)
  18. captures:
  19. 0: punctuation.definition.comment.ts
  20. push:
  21. - meta_scope: comment.block.documentation.ts
  22. - match: \*/
  23. captures:
  24. 0: punctuation.definition.comment.ts
  25. pop: true
  26. - include: docblock
  27. - match: (/\*)(?:\s*((@)internal)(?=\s|(\*/)))?
  28. captures:
  29. 1: punctuation.definition.comment.ts
  30. 2: storage.type.internaldeclaration.ts
  31. 3: punctuation.decorator.internaldeclaration.ts
  32. push:
  33. - meta_scope: comment.block.ts
  34. - match: \*/
  35. captures:
  36. 0: punctuation.definition.comment.ts
  37. pop: true
  38. - match: '(^[ \t]+)?((//)(?:\s*((@)internal)(?=\s|$))?)'
  39. captures:
  40. 1: punctuation.whitespace.comment.leading.ts
  41. 2: comment.line.double-slash.ts
  42. 3: punctuation.definition.comment.ts
  43. 4: storage.type.internaldeclaration.ts
  44. 5: punctuation.decorator.internaldeclaration.ts
  45. push:
  46. - meta_content_scope: comment.line.double-slash.ts
  47. - match: (?=^)
  48. pop: true
  49. access-modifier:
  50. - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(abstract|public|protected|private|readonly|static)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))'
  51. scope: storage.modifier.ts
  52. after-operator-block-as-object-literal:
  53. - match: '(?<=[=(,\[?+!]|await|return|yield|throw|in|of|typeof|&&|\|\||\*)\s*(\{)'
  54. captures:
  55. 1: punctuation.definition.block.ts
  56. push:
  57. - meta_scope: meta.objectliteral.ts
  58. - match: '\}'
  59. captures:
  60. 0: punctuation.definition.block.ts
  61. pop: true
  62. - include: object-member
  63. array-binding-pattern:
  64. - match: '(?:(\.\.\.)\s*)?(\[)'
  65. captures:
  66. 1: keyword.operator.rest.ts
  67. 2: punctuation.definition.binding-pattern.array.ts
  68. push:
  69. - match: '\]'
  70. captures:
  71. 0: punctuation.definition.binding-pattern.array.ts
  72. pop: true
  73. - include: binding-element
  74. - include: punctuation-comma
  75. array-literal:
  76. - match: '\['
  77. captures:
  78. 0: meta.brace.square.ts
  79. push:
  80. - meta_scope: meta.array.literal.ts
  81. - match: '\]'
  82. captures:
  83. 0: meta.brace.square.ts
  84. pop: true
  85. - include: expression
  86. - include: punctuation-comma
  87. arrow-function:
  88. - match: '(?:(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(\basync)\s+)?([_$[:alpha:]][_$[:alnum:]]*)\s*(?==>)'
  89. scope: meta.arrow.ts
  90. captures:
  91. 1: storage.modifier.async.ts
  92. 2: variable.parameter.ts
  93. - match: |-
  94. (?x) (?:
  95. (?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(\basync)
  96. )? ((?<![})!\]])\s*
  97. (?=
  98. # sure shot arrow functions even if => is on new line
  99. (
  100. [(]\s*
  101. (
  102. ([)]\s*:) | # ():
  103. ((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param:
  104. )
  105. ) |
  106. (
  107. [<]\s*[_$[:alpha:]][_$[:alnum:]]*\s+extends\s*[^=>] # < typeparam extends
  108. ) |
  109. # arrow function possible to detect only with => on same line
  110. (
  111. (<\s*([_$[:alpha:]]|(\{[^\{\}]*\})|(\([^\(\)]*\))|(\[[^\[\]]*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{[^\{\}]*\})|(\([^\(\)]*\))|(\[[^\[\]]*\]))([^=<>]|=[^<])*\>)*>\s*)? # typeparameters
  112. \(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[^()]*)?\))*)?\) # parameteres
  113. (\s*:\s*([^<>\(\)]|\<[^<>]+\>|\([^\(\)]+\))+)? # return type
  114. \s*=> # arrow operator
  115. )
  116. )
  117. )
  118. captures:
  119. 1: storage.modifier.async.ts
  120. push:
  121. - meta_scope: meta.arrow.ts
  122. - match: '(?==>|\{|(^\s*(export|function|class|interface|let|var|const|import|enum|namespace|module|type|abstract|declare)\s+))'
  123. pop: true
  124. - include: comment
  125. - include: type-parameters
  126. - include: function-parameters
  127. - include: arrow-return-type
  128. - match: "=>"
  129. captures:
  130. 0: storage.type.function.arrow.ts
  131. push:
  132. - meta_scope: meta.arrow.ts
  133. - match: '(?<=\}|\S)(?<!=>)|((?!\{)(?=\S))'
  134. pop: true
  135. - include: decl-block
  136. - include: expression
  137. arrow-return-type:
  138. - match: (?<=\))\s*(:)
  139. captures:
  140. 1: keyword.operator.type.annotation.ts
  141. push:
  142. - meta_scope: meta.return.type.arrow.ts
  143. - match: '(?==>|\{|(^\s*(export|function|class|interface|let|var|const|import|enum|namespace|module|type|abstract|declare)\s+))'
  144. pop: true
  145. - match: '(?<=[:])(?=\s*\{)'
  146. push:
  147. - match: '(?<=\})'
  148. pop: true
  149. - include: type-object
  150. - include: type-predicate-operator
  151. - include: type
  152. binding-element:
  153. - include: comment
  154. - include: object-binding-pattern
  155. - include: array-binding-pattern
  156. - include: destructuring-variable-rest
  157. - include: variable-initializer
  158. boolean-literal:
  159. - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))true(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))'
  160. scope: constant.language.boolean.true.ts
  161. - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))false(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))'
  162. scope: constant.language.boolean.false.ts
  163. brackets:
  164. - match: "{"
  165. push:
  166. - match: '}|(?=\*/)'
  167. pop: true
  168. - include: brackets
  169. - match: '\['
  170. push:
  171. - match: '\]|(?=\*/)'
  172. pop: true
  173. - include: brackets
  174. cast:
  175. - match: '(?:(?<=return|throw|yield|await|default|[=(,:>*?\&\|\^]|[^_$[:alnum:]](?:\+\+|\-\-)|[^\+]\+|[^\-]\-))\s*(<)(?!<?\=)'
  176. captures:
  177. 1: meta.brace.angle.ts
  178. push:
  179. - meta_scope: cast.expr.ts
  180. - match: (\>)\s*
  181. captures:
  182. 1: meta.brace.angle.ts
  183. pop: true
  184. - include: type
  185. - match: '(?:(?<=^))\s*(<)(?=[_$[:alpha:]][_$[:alnum:]]*\s*>)'
  186. captures:
  187. 1: meta.brace.angle.ts
  188. push:
  189. - meta_scope: cast.expr.ts
  190. - match: (\>)\s*
  191. captures:
  192. 1: meta.brace.angle.ts
  193. pop: true
  194. - include: type
  195. class-declaration:
  196. - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(export)\s+)?\b(?:(abstract)\s+)?\b(class)\b(?=\s+|/[/*])'
  197. captures:
  198. 1: keyword.control.export.ts
  199. 2: storage.modifier.ts
  200. 3: storage.type.class.ts
  201. push:
  202. - meta_scope: meta.class.ts
  203. - match: '(?<=\})'
  204. pop: true
  205. - include: class-declaration-or-expression-patterns
  206. class-declaration-or-expression-patterns:
  207. - include: comment
  208. - include: class-or-interface-heritage
  209. - match: "[_$[:alpha:]][_$[:alnum:]]*"
  210. captures:
  211. 0: entity.name.type.class.ts
  212. - include: type-parameters
  213. - include: class-or-interface-body
  214. class-expression:
  215. - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(class)\b(?=\s+|[<{]|/[/*])'
  216. captures:
  217. 1: storage.type.class.ts
  218. push:
  219. - meta_scope: meta.class.ts
  220. - match: '(?<=\})'
  221. pop: true
  222. - include: class-declaration-or-expression-patterns
  223. class-or-interface-body:
  224. - match: '\{'
  225. captures:
  226. 0: punctuation.definition.block.ts
  227. push:
  228. - match: '\}'
  229. captures:
  230. 0: punctuation.definition.block.ts
  231. pop: true
  232. - include: string
  233. - include: comment
  234. - include: decorator
  235. - include: method-declaration
  236. - include: indexer-declaration
  237. - include: field-declaration
  238. - include: type-annotation
  239. - include: variable-initializer
  240. - include: access-modifier
  241. - include: property-accessor
  242. - include: after-operator-block-as-object-literal
  243. - include: decl-block
  244. - include: expression
  245. - include: punctuation-comma
  246. - include: punctuation-semicolon
  247. class-or-interface-heritage:
  248. - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:\b(extends|implements)\b)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))'
  249. captures:
  250. 1: storage.modifier.ts
  251. push:
  252. - match: '(?=\{)'
  253. pop: true
  254. - include: comment
  255. - include: class-or-interface-heritage
  256. - include: type-parameters
  257. - include: expressionWithoutIdentifiers
  258. - match: '([_$[:alpha:]][_$[:alnum:]]*)\s*(?:(\.)|(\?\.(?!\s*[[:digit:]])))(?=\s*[_$[:alpha:]][_$[:alnum:]]*(\s*\??\.\s*[_$[:alpha:]][_$[:alnum:]]*)*\s*)'
  259. captures:
  260. 1: entity.name.type.module.ts
  261. 2: punctuation.accessor.ts
  262. 3: punctuation.accessor.optional.ts
  263. - match: "([_$[:alpha:]][_$[:alnum:]]*)"
  264. captures:
  265. 1: entity.other.inherited-class.ts
  266. - include: expressionPunctuations
  267. control-statement:
  268. - include: switch-statement
  269. - include: for-loop
  270. - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(catch|finally|throw|try)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))'
  271. scope: keyword.control.trycatch.ts
  272. - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(break|continue|do|goto|while)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))'
  273. scope: keyword.control.loop.ts
  274. - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(return)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))'
  275. scope: keyword.control.flow.ts
  276. - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(case|default|switch)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))'
  277. scope: keyword.control.switch.ts
  278. - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(else|if)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))'
  279. scope: keyword.control.conditional.ts
  280. - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(with)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))'
  281. scope: keyword.control.with.ts
  282. - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(debugger)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))'
  283. scope: keyword.other.debugger.ts
  284. - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(declare)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))'
  285. scope: storage.modifier.ts
  286. decl-block:
  287. - match: '\{'
  288. captures:
  289. 0: punctuation.definition.block.ts
  290. push:
  291. - meta_scope: meta.block.ts
  292. - match: '\}'
  293. captures:
  294. 0: punctuation.definition.block.ts
  295. pop: true
  296. - include: statements
  297. declaration:
  298. - include: decorator
  299. - include: var-expr
  300. - include: function-declaration
  301. - include: class-declaration
  302. - include: interface-declaration
  303. - include: enum-declaration
  304. - include: namespace-declaration
  305. - include: type-alias-declaration
  306. - include: import-equals-declaration
  307. - include: import-declaration
  308. - include: export-declaration
  309. decorator:
  310. - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))\@'
  311. captures:
  312. 0: punctuation.decorator.ts
  313. push:
  314. - meta_scope: meta.decorator.ts
  315. - match: (?=\s)
  316. pop: true
  317. - include: expression
  318. destructuring-parameter:
  319. - match: '(?<!=|:)\s*(\{)'
  320. captures:
  321. 1: punctuation.definition.binding-pattern.object.ts
  322. push:
  323. - meta_scope: meta.parameter.object-binding-pattern.ts
  324. - match: '\}'
  325. captures:
  326. 0: punctuation.definition.binding-pattern.object.ts
  327. pop: true
  328. - include: parameter-object-binding-element
  329. - match: '(?<!=|:)\s*(\[)'
  330. captures:
  331. 1: punctuation.definition.binding-pattern.array.ts
  332. push:
  333. - meta_scope: meta.paramter.array-binding-pattern.ts
  334. - match: '\]'
  335. captures:
  336. 0: punctuation.definition.binding-pattern.array.ts
  337. pop: true
  338. - include: parameter-binding-element
  339. - include: punctuation-comma
  340. destructuring-parameter-rest:
  341. - match: '(?:(\.\.\.)\s*)?([_$[:alpha:]][_$[:alnum:]]*)'
  342. captures:
  343. 1: keyword.operator.rest.ts
  344. 2: variable.parameter.ts
  345. destructuring-variable:
  346. - match: '(?<!=|:|of|in)\s*(?=\{)'
  347. push:
  348. - meta_scope: meta.object-binding-pattern-variable.ts
  349. - match: '(?=$|^|[;,=}]|(\s+(of|in)\s+))'
  350. pop: true
  351. - include: object-binding-pattern
  352. - include: type-annotation
  353. - include: comment
  354. - match: '(?<!=|:|of|in)\s*(?=\[)'
  355. push:
  356. - meta_scope: meta.array-binding-pattern-variable.ts
  357. - match: '(?=$|^|[;,=}]|(\s+(of|in)\s+))'
  358. pop: true
  359. - include: array-binding-pattern
  360. - include: type-annotation
  361. - include: comment
  362. destructuring-variable-rest:
  363. - match: '(?:(\.\.\.)\s*)?([_$[:alpha:]][_$[:alnum:]]*)'
  364. captures:
  365. 1: keyword.operator.rest.ts
  366. 2: meta.definition.variable.ts variable.other.readwrite.ts
  367. directives:
  368. - match: '^(///)\s*(?=<(reference|amd-dependency|amd-module)(\s+(path|types|no-default-lib|name)\s*=\s*((\''([^\''\\]|\\\''|\\)*\'')|(\"([^\"\\]|\\\"|\\)*\")))+\s*/>\s*$)'
  369. captures:
  370. 1: punctuation.definition.comment.ts
  371. push:
  372. - meta_scope: comment.line.triple-slash.directive.ts
  373. - match: (?=^)
  374. pop: true
  375. - match: (<)(reference|amd-dependency|amd-module)
  376. captures:
  377. 1: punctuation.definition.tag.directive.ts
  378. 2: entity.name.tag.directive.ts
  379. push:
  380. - meta_scope: meta.tag.ts
  381. - match: />
  382. captures:
  383. 0: punctuation.definition.tag.directive.ts
  384. pop: true
  385. - match: path|types|no-default-lib|name
  386. scope: entity.other.attribute-name.directive.ts
  387. - match: "="
  388. scope: keyword.operator.assignment.ts
  389. - include: string
  390. docblock:
  391. - match: |-
  392. (?x)
  393. ((@)(?:access|api))
  394. \s+
  395. (private|protected|public)
  396. \b
  397. captures:
  398. 1: storage.type.class.jsdoc
  399. 2: punctuation.definition.block.tag.jsdoc
  400. 3: constant.language.access-type.jsdoc
  401. - match: |-
  402. (?x)
  403. ((@)author)
  404. \s+
  405. (
  406. [^@\s<>*/]
  407. (?:[^@<>*/]|\*[^/])*
  408. )
  409. (?:
  410. \s*
  411. (<)
  412. ([^>\s]+)
  413. (>)
  414. )?
  415. captures:
  416. 1: storage.type.class.jsdoc
  417. 2: punctuation.definition.block.tag.jsdoc
  418. 3: entity.name.type.instance.jsdoc
  419. 4: punctuation.definition.bracket.angle.begin.jsdoc
  420. 5: constant.other.email.link.underline.jsdoc
  421. 6: punctuation.definition.bracket.angle.end.jsdoc
  422. - match: |-
  423. (?x)
  424. ((@)borrows) \s+
  425. ((?:[^@\s*/]|\*[^/])+) # <that namepath>
  426. \s+ (as) \s+ # as
  427. ((?:[^@\s*/]|\*[^/])+) # <this namepath>
  428. captures:
  429. 1: storage.type.class.jsdoc
  430. 2: punctuation.definition.block.tag.jsdoc
  431. 3: entity.name.type.instance.jsdoc
  432. 4: keyword.operator.control.jsdoc
  433. 5: entity.name.type.instance.jsdoc
  434. - match: ((@)example)\s+
  435. captures:
  436. 1: storage.type.class.jsdoc
  437. 2: punctuation.definition.block.tag.jsdoc
  438. push:
  439. - meta_scope: meta.example.jsdoc
  440. - match: (?=@|\*/)
  441. pop: true
  442. - match: ^\s\*\s+
  443. - match: \G(<)caption(>)
  444. captures:
  445. 0: entity.name.tag.inline.jsdoc
  446. 1: punctuation.definition.bracket.angle.begin.jsdoc
  447. 2: punctuation.definition.bracket.angle.end.jsdoc
  448. push:
  449. - meta_content_scope: constant.other.description.jsdoc
  450. - match: (</)caption(>)|(?=\*/)
  451. captures:
  452. 0: entity.name.tag.inline.jsdoc
  453. 1: punctuation.definition.bracket.angle.begin.jsdoc
  454. 2: punctuation.definition.bracket.angle.end.jsdoc
  455. pop: true
  456. - match: '[^\s@*](?:[^*]|\*[^/])*'
  457. captures:
  458. 0: source.embedded.ts
  459. - match: (?x) ((@)kind) \s+ (class|constant|event|external|file|function|member|mixin|module|namespace|typedef) \b
  460. captures:
  461. 1: storage.type.class.jsdoc
  462. 2: punctuation.definition.block.tag.jsdoc
  463. 3: constant.language.symbol-type.jsdoc
  464. - match: |-
  465. (?x)
  466. ((@)see)
  467. \s+
  468. (?:
  469. # URL
  470. (
  471. (?=https?://)
  472. (?:[^\s*]|\*[^/])+
  473. )
  474. |
  475. # JSDoc namepath
  476. (
  477. (?!
  478. # Avoid matching bare URIs (also acceptable as links)
  479. https?://
  480. |
  481. # Avoid matching {@inline tags}; we match those below
  482. (?:\[[^\[\]]*\])? # Possible description [preceding]{@tag}
  483. {@(?:link|linkcode|linkplain|tutorial)\b
  484. )
  485. # Matched namepath
  486. (?:[^@\s*/]|\*[^/])+
  487. )
  488. )
  489. captures:
  490. 1: storage.type.class.jsdoc
  491. 2: punctuation.definition.block.tag.jsdoc
  492. 3: variable.other.link.underline.jsdoc
  493. 4: entity.name.type.instance.jsdoc
  494. - match: |-
  495. (?x)
  496. ((@)template)
  497. \s+
  498. # One or more valid identifiers
  499. (
  500. [A-Za-z_$] # First character: non-numeric word character
  501. [\w$.\[\]]* # Rest of identifier
  502. (?: # Possible list of additional identifiers
  503. \s* , \s*
  504. [A-Za-z_$]
  505. [\w$.\[\]]*
  506. )*
  507. )
  508. captures:
  509. 1: storage.type.class.jsdoc
  510. 2: punctuation.definition.block.tag.jsdoc
  511. 3: variable.other.jsdoc
  512. - match: |-
  513. (?x)
  514. (
  515. (@)
  516. (?:arg|argument|const|constant|member|namespace|param|var)
  517. )
  518. \s+
  519. (
  520. [A-Za-z_$]
  521. [\w$.\[\]]*
  522. )
  523. captures:
  524. 1: storage.type.class.jsdoc
  525. 2: punctuation.definition.block.tag.jsdoc
  526. 3: variable.other.jsdoc
  527. - match: '((@)typedef)\s+(?={)'
  528. captures:
  529. 1: storage.type.class.jsdoc
  530. 2: punctuation.definition.block.tag.jsdoc
  531. push:
  532. - match: '(?=\s|\*/|[^{}\[\]A-Za-z_$])'
  533. pop: true
  534. - include: jsdoctype
  535. - match: '(?:[^@\s*/]|\*[^/])+'
  536. scope: entity.name.type.instance.jsdoc
  537. - match: '((@)(?:arg|argument|const|constant|member|namespace|param|prop|property|var))\s+(?={)'
  538. captures:
  539. 1: storage.type.class.jsdoc
  540. 2: punctuation.definition.block.tag.jsdoc
  541. push:
  542. - match: '(?=\s|\*/|[^{}\[\]A-Za-z_$])'
  543. pop: true
  544. - include: jsdoctype
  545. - match: '([A-Za-z_$][\w$.\[\]]*)'
  546. scope: variable.other.jsdoc
  547. - match: |-
  548. (?x)
  549. (\[)\s*
  550. [\w$]+
  551. (?:
  552. (?:\[\])? # Foo[ ].bar properties within an array
  553. \. # Foo.Bar namespaced parameter
  554. [\w$]+
  555. )*
  556. (?:
  557. \s*
  558. (=) # [foo=bar] Default parameter value
  559. \s*
  560. (
  561. # The inner regexes are to stop the match early at */ and to not stop at escaped quotes
  562. (?>
  563. "(?:(?:\*(?!/))|(?:\\(?!"))|[^*\\])*?" | # [foo="bar"] Double-quoted
  564. '(?:(?:\*(?!/))|(?:\\(?!'))|[^*\\])*?' | # [foo='bar'] Single-quoted
  565. \[ (?:(?:\*(?!/))|[^*])*? \] | # [foo=[1,2]] Array literal
  566. (?:(?:\*(?!/))|\s(?!\s*\])|\[.*?(?:\]|(?=\*/))|[^*\s\[\]])* # Everything else
  567. )*
  568. )
  569. )?
  570. \s*(?:(\])((?:[^*\s]|\*[^\s/])+)?|(?=\*/))
  571. scope: variable.other.jsdoc
  572. captures:
  573. 1: punctuation.definition.optional-value.begin.bracket.square.jsdoc
  574. 2: keyword.operator.assignment.jsdoc
  575. 3: source.embedded.ts
  576. 4: punctuation.definition.optional-value.end.bracket.square.jsdoc
  577. 5: invalid.illegal.syntax.jsdoc
  578. - match: |-
  579. (?x)
  580. (
  581. (@)
  582. (?:define|enum|exception|export|extends|lends|implements|modifies
  583. |namespace|private|protected|returns?|suppress|this|throws|type
  584. |yields?)
  585. )
  586. \s+(?={)
  587. captures:
  588. 1: storage.type.class.jsdoc
  589. 2: punctuation.definition.block.tag.jsdoc
  590. push:
  591. - match: '(?=\s|\*/|[^{}\[\]A-Za-z_$])'
  592. pop: true
  593. - include: jsdoctype
  594. - match: |-
  595. (?x)
  596. (
  597. (@)
  598. (?:alias|augments|callback|constructs|emits|event|fires|exports?
  599. |extends|external|function|func|host|lends|listens|interface|memberof!?
  600. |method|module|mixes|mixin|name|requires|see|this|typedef|uses)
  601. )
  602. \s+
  603. (
  604. (?:
  605. [^{}@\s*] | \*[^/]
  606. )+
  607. )
  608. captures:
  609. 1: storage.type.class.jsdoc
  610. 2: punctuation.definition.block.tag.jsdoc
  611. 3: entity.name.type.instance.jsdoc
  612. - match: '((@)(?:default(?:value)?|license|version))\s+(([''''"]))'
  613. captures:
  614. 1: storage.type.class.jsdoc
  615. 2: punctuation.definition.block.tag.jsdoc
  616. 3: variable.other.jsdoc
  617. 4: punctuation.definition.string.begin.jsdoc
  618. push:
  619. - meta_content_scope: variable.other.jsdoc
  620. - match: (\3)|(?=$|\*/)
  621. captures:
  622. 0: variable.other.jsdoc
  623. 1: punctuation.definition.string.end.jsdoc
  624. pop: true
  625. - match: '((@)(?:default(?:value)?|license|tutorial|variation|version))\s+([^\s*]+)'
  626. captures:
  627. 1: storage.type.class.jsdoc
  628. 2: punctuation.definition.block.tag.jsdoc
  629. 3: variable.other.jsdoc
  630. - 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'
  631. scope: storage.type.class.jsdoc
  632. captures:
  633. 1: punctuation.definition.block.tag.jsdoc
  634. - include: inline-tags
  635. enum-declaration:
  636. - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(\bexport)\s+)?(?:\b(const)\s+)?\b(enum)\s+([_$[:alpha:]][_$[:alnum:]]*)'
  637. captures:
  638. 1: keyword.control.export.ts
  639. 2: storage.modifier.ts
  640. 3: storage.type.enum.ts
  641. 4: entity.name.type.enum.ts
  642. push:
  643. - meta_scope: meta.enum.declaration.ts
  644. - match: '(?<=\})'
  645. pop: true
  646. - include: comment
  647. - match: '\{'
  648. captures:
  649. 0: punctuation.definition.block.ts
  650. push:
  651. - match: '\}'
  652. captures:
  653. 0: punctuation.definition.block.ts
  654. pop: true
  655. - include: comment
  656. - match: "([_$[:alpha:]][_$[:alnum:]]*)"
  657. captures:
  658. 0: variable.other.enummember.ts
  659. push:
  660. - match: '(?=,|\}|$)'
  661. pop: true
  662. - include: comment
  663. - include: variable-initializer
  664. - match: '(?=((\''([^\''\\]|\\\''|\\)*\'')|(\"([^\"\\]|\\\"|\\)*\")|(\[([^\[\]]|\[[^\[\]]*\])+\])))'
  665. push:
  666. - match: '(?=,|\}|$)'
  667. pop: true
  668. - include: string
  669. - include: array-literal
  670. - include: comment
  671. - include: variable-initializer
  672. - include: punctuation-comma
  673. export-declaration:
  674. - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(export)\s+(as)\s+(namespace)\s+([_$[:alpha:]][_$[:alnum:]]*)'
  675. captures:
  676. 1: keyword.control.export.ts
  677. 2: keyword.control.as.ts
  678. 3: storage.type.namespace.ts
  679. 4: entity.name.type.module.ts
  680. - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(export)(?:(?:\s*(=))|(?:\s+(default)(?=\s+)))'
  681. captures:
  682. 1: keyword.control.export.ts
  683. 2: keyword.operator.assignment.ts
  684. 3: keyword.control.default.ts
  685. push:
  686. - meta_scope: meta.export.default.ts
  687. - match: (?=;|$|\babstract\b|\basync\b|\bclass\b|\bconst\b|\bdeclare\b|\benum\b|\bexport\b|\bfunction\b|\bimport\b|\binterface\b|\blet\b|\bmodule\b|\bnamespace\b|\btype\b|\bvar\b)
  688. pop: true
  689. - include: expression
  690. - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(export)(?!\s*:)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))'
  691. captures:
  692. 0: keyword.control.export.ts
  693. push:
  694. - meta_scope: meta.export.ts
  695. - match: (?=;|$|\babstract\b|\basync\b|\bclass\b|\bconst\b|\bdeclare\b|\benum\b|\bexport\b|\bfunction\b|\bimport\b|\binterface\b|\blet\b|\bmodule\b|\bnamespace\b|\btype\b|\bvar\b)
  696. pop: true
  697. - include: import-export-declaration
  698. expression:
  699. - include: expressionWithoutIdentifiers
  700. - include: identifiers
  701. - include: expressionPunctuations
  702. expression-operators:
  703. - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(await)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))'
  704. scope: keyword.control.flow.ts
  705. - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(yield)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))(?:\s*(\*))?'
  706. captures:
  707. 1: keyword.control.flow.ts
  708. 2: keyword.generator.asterisk.ts
  709. - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))delete(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))'
  710. scope: keyword.operator.expression.delete.ts
  711. - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))in(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))'
  712. scope: keyword.operator.expression.in.ts
  713. - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))of(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))'
  714. scope: keyword.operator.expression.of.ts
  715. - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))instanceof(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))'
  716. scope: keyword.operator.expression.instanceof.ts
  717. - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))new(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))'
  718. scope: keyword.operator.new.ts
  719. - include: typeof-operator
  720. - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))void(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))'
  721. scope: keyword.operator.expression.void.ts
  722. - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(as)\s+'
  723. captures:
  724. 1: keyword.control.as.ts
  725. push:
  726. - match: '(?=$|^|[;,:})\]]|((?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(as)\s+))'
  727. pop: true
  728. - include: type
  729. - match: \.\.\.
  730. scope: keyword.operator.spread.ts
  731. - match: \*=|(?<!\()/=|%=|\+=|\-=
  732. scope: keyword.operator.assignment.compound.ts
  733. - match: \&=|\^=|<<=|>>=|>>>=|\|=
  734. scope: keyword.operator.assignment.compound.bitwise.ts
  735. - match: "<<|>>>|>>"
  736. scope: keyword.operator.bitwise.shift.ts
  737. - match: "===|!==|==|!="
  738. scope: keyword.operator.comparison.ts
  739. - match: <=|>=|<>|<|>
  740. scope: keyword.operator.relational.ts
  741. - match: \!|&&|\|\|
  742. scope: keyword.operator.logical.ts
  743. - match: \&|~|\^|\|
  744. scope: keyword.operator.bitwise.ts
  745. - match: \=
  746. scope: keyword.operator.assignment.ts
  747. - match: "--"
  748. scope: keyword.operator.decrement.ts
  749. - match: \+\+
  750. scope: keyword.operator.increment.ts
  751. - match: '%|\*|/|-|\+'
  752. scope: keyword.operator.arithmetic.ts
  753. - match: '(?<=[_$[:alnum:])])\s*(/)(?![/*])'
  754. captures:
  755. 1: keyword.operator.arithmetic.ts
  756. expressionPunctuations:
  757. - include: punctuation-comma
  758. - include: punctuation-accessor
  759. expressionWithoutIdentifiers:
  760. - include: string
  761. - include: regex
  762. - include: template
  763. - include: comment
  764. - include: function-expression
  765. - include: class-expression
  766. - include: arrow-function
  767. - include: cast
  768. - include: ternary-expression
  769. - include: new-expr
  770. - include: object-literal
  771. - include: expression-operators
  772. - include: function-call
  773. - include: literal
  774. - include: support-objects
  775. - include: paren-expression
  776. field-declaration:
  777. - match: '(?<!\()(?:(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(readonly)\s+)?(?=(([_$[:alpha:]][_$[:alnum:]]*)|(\''([^\''\\]|\\\''|\\)*\'')|(\"([^\"\\]|\\\"|\\)*\")|(\[([^\[\]]|\[[^\[\]]*\])+\]))\s*(\?\s*)?(=|:))'
  778. captures:
  779. 1: storage.modifier.ts
  780. push:
  781. - meta_scope: meta.field.declaration.ts
  782. - match: '(?=\}|;|,|$|(^(?!(([_$[:alpha:]][_$[:alnum:]]*)|(\''([^\''\\]|\\\''|\\)*\'')|(\"([^\"\\]|\\\"|\\)*\")|(\[([^\[\]]|\[[^\[\]]*\])+\]))\s*(\?\s*)?(=|:))))|(?<=\})'
  783. pop: true
  784. - include: variable-initializer
  785. - match: '(?=(([_$[:alpha:]][_$[:alnum:]]*)|(\''([^\''\\]|\\\''|\\)*\'')|(\"([^\"\\]|\\\"|\\)*\")|(\[([^\[\]]|\[[^\[\]]*\])+\]))\s*(\?\s*)?(=|:))'
  786. push:
  787. - match: '(?=[};,=]|$|(^(?!(([_$[:alpha:]][_$[:alnum:]]*)|(\''([^\''\\]|\\\''|\\)*\'')|(\"([^\"\\]|\\\"|\\)*\")|(\[([^\[\]]|\[[^\[\]]*\])+\]))\s*(\?\s*)?(=|:))))|(?<=\})'
  788. pop: true
  789. - include: type-annotation
  790. - include: string
  791. - include: array-literal
  792. - include: comment
  793. - match: |-
  794. (?x)([_$[:alpha:]][_$[:alnum:]]*)(?=(\?\s*)?\s*
  795. # function assignment |
  796. (=\s*(
  797. ((async\s+)?(
  798. (function\s*[(<*]) |
  799. (function\s+) |
  800. ([_$[:alpha:]][_$[:alnum:]]*\s*=>)
  801. )) |
  802. ((async\s*)?(
  803. # sure shot arrow functions even if => is on new line
  804. (
  805. [(]\s*
  806. (
  807. ([)]\s*:) | # ():
  808. ((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param:
  809. )
  810. ) |
  811. (
  812. [<]\s*[_$[:alpha:]][_$[:alnum:]]*\s+extends\s*[^=>] # < typeparam extends
  813. ) |
  814. # arrow function possible to detect only with => on same line
  815. (
  816. (<\s*([_$[:alpha:]]|(\{[^\{\}]*\})|(\([^\(\)]*\))|(\[[^\[\]]*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{[^\{\}]*\})|(\([^\(\)]*\))|(\[[^\[\]]*\]))([^=<>]|=[^<])*\>)*>\s*)? # typeparameters
  817. \(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[^()]*)?\))*)?\) # parameteres
  818. (\s*:\s*([^<>\(\)]|\<[^<>]+\>|\([^\(\)]+\))+)? # return type
  819. \s*=> # arrow operator
  820. )
  821. ))
  822. )) |
  823. # typeannotation is fn type: < | () | (... | (param: | (param, | (param? | (param= | (param) =>
  824. (:\s*(
  825. (<) |
  826. ([(]\s*(
  827. ([)]) |
  828. (\.\.\.) |
  829. ([_$[:alnum:]]+\s*(
  830. ([:,?=])|
  831. ([)]\s*=>)
  832. ))
  833. ))
  834. )))
  835. scope: meta.definition.property.ts entity.name.function.ts
  836. - match: "[_$[:alpha:]][_$[:alnum:]]*"
  837. scope: meta.definition.property.ts variable.object.property.ts
  838. - match: \?
  839. scope: keyword.operator.optional.ts
  840. for-loop:
  841. - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(for)(?:\s+(await))?\s*(\()'
  842. captures:
  843. 1: keyword.control.loop.ts
  844. 2: keyword.control.loop.ts
  845. 3: meta.brace.round.ts
  846. push:
  847. - match: \)
  848. captures:
  849. 0: meta.brace.round.ts
  850. pop: true
  851. - include: var-expr
  852. - include: expression
  853. - include: punctuation-semicolon
  854. function-body:
  855. - include: comment
  856. - include: type-parameters
  857. - include: function-parameters
  858. - include: return-type
  859. - include: decl-block
  860. function-call:
  861. - match: '(?=(([_$[:alpha:]][_$[:alnum:]]*\s*\??\.\s*)*|(\??\.\s*)?)([_$[:alpha:]][_$[:alnum:]]*)\s*(\?\.\s*)?(<\s*(([_$[:alpha:]]|(\{[^\{\}]*\})|(\([^\(\)]*\))|(\[[^\[\]]*\]))|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))([^<>\(]|(\([^\(\)]*\))|\<\s*(([_$[:alpha:]]|(\{[^\{\}]*\})|(\([^\(\)]*\))|(\[[^\[\]]*\]))|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))([^<>\(]|(\([^\(\)]*\)))*\>)*>\s*)?\()'
  862. push:
  863. - match: '(?<=\))(?!(([_$[:alpha:]][_$[:alnum:]]*\s*\??\.\s*)*|(\??\.\s*)?)([_$[:alpha:]][_$[:alnum:]]*)\s*(\?\.\s*)?(<\s*(([_$[:alpha:]]|(\{[^\{\}]*\})|(\([^\(\)]*\))|(\[[^\[\]]*\]))|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))([^<>\(]|(\([^\(\)]*\))|\<\s*(([_$[:alpha:]]|(\{[^\{\}]*\})|(\([^\(\)]*\))|(\[[^\[\]]*\]))|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))([^<>\(]|(\([^\(\)]*\)))*\>)*>\s*)?\()'
  864. pop: true
  865. - match: '(?=(([_$[:alpha:]][_$[:alnum:]]*\s*\??\.\s*)*|(\??\.\s*)?)([_$[:alpha:]][_$[:alnum:]]*))'
  866. push:
  867. - meta_scope: meta.function-call.ts
  868. - match: '(?=\s*(\?\.\s*)?(<\s*(([_$[:alpha:]]|(\{[^\{\}]*\})|(\([^\(\)]*\))|(\[[^\[\]]*\]))|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))([^<>\(]|(\([^\(\)]*\))|\<\s*(([_$[:alpha:]]|(\{[^\{\}]*\})|(\([^\(\)]*\))|(\[[^\[\]]*\]))|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))([^<>\(]|(\([^\(\)]*\)))*\>)*>\s*)?\()'
  869. pop: true
  870. - include: literal
  871. - include: support-objects
  872. - include: object-identifiers
  873. - include: punctuation-accessor
  874. - match: '(?:(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))import(?=\s*[\(]\s*[\"\''\`]))'
  875. scope: keyword.operator.expression.import.ts
  876. - match: "([_$[:alpha:]][_$[:alnum:]]*)"
  877. scope: entity.name.function.ts
  878. - include: comment
  879. - match: \?\.
  880. scope: meta.function-call.ts punctuation.accessor.optional.ts
  881. - match: \<
  882. captures:
  883. 0: punctuation.definition.typeparameters.begin.ts
  884. push:
  885. - meta_scope: meta.type.parameters.ts
  886. - match: \>
  887. captures:
  888. 0: punctuation.definition.typeparameters.end.ts
  889. pop: true
  890. - include: type
  891. - include: punctuation-comma
  892. - include: paren-expression
  893. function-declaration:
  894. - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(export)\s+)?(?:(async)\s+)?(function\b)(?:\s*(\*))?(?:(?:\s+|(?<=\*))([_$[:alpha:]][_$[:alnum:]]*))?\s*'
  895. captures:
  896. 1: keyword.control.export.ts
  897. 2: storage.modifier.async.ts
  898. 3: storage.type.function.ts
  899. 4: keyword.generator.asterisk.ts
  900. 5: meta.definition.function.ts entity.name.function.ts
  901. push:
  902. - meta_scope: meta.function.ts
  903. - match: '(?=$|^|;)|(?<=\})'
  904. pop: true
  905. - include: function-body
  906. function-expression:
  907. - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(async)\s+)?(function\b)(?:\s*(\*))?(?:(?:\s+|(?<=\*))([_$[:alpha:]][_$[:alnum:]]*))?\s*'
  908. captures:
  909. 1: storage.modifier.async.ts
  910. 2: storage.type.function.ts
  911. 3: keyword.generator.asterisk.ts
  912. 4: meta.definition.function.ts entity.name.function.ts
  913. push:
  914. - meta_scope: meta.function.expression.ts
  915. - match: '(?<=\})'
  916. pop: true
  917. - include: function-body
  918. function-parameters:
  919. - match: \(
  920. captures:
  921. 0: punctuation.definition.parameters.begin.ts
  922. push:
  923. - meta_scope: meta.parameters.ts
  924. - match: \)
  925. captures:
  926. 0: punctuation.definition.parameters.end.ts
  927. pop: true
  928. - include: comment
  929. - include: decorator
  930. - include: destructuring-parameter
  931. - include: parameter-name
  932. - include: type-annotation
  933. - include: variable-initializer
  934. - match: ","
  935. scope: punctuation.separator.parameter.ts
  936. identifiers:
  937. - include: object-identifiers
  938. - match: |-
  939. (?x)(?:(?:(\.)|(\?\.(?!\s*[[:digit:]])))\s*)?([_$[:alpha:]][_$[:alnum:]]*)(?=\s*=\s*(
  940. ((async\s+)?(
  941. (function\s*[(<*]) |
  942. (function\s+) |
  943. ([_$[:alpha:]][_$[:alnum:]]*\s*=>)
  944. )) |
  945. ((async\s*)?(
  946. # sure shot arrow functions even if => is on new line
  947. (
  948. [(]\s*
  949. (
  950. ([)]\s*:) | # ():
  951. ((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param:
  952. )
  953. ) |
  954. (
  955. [<]\s*[_$[:alpha:]][_$[:alnum:]]*\s+extends\s*[^=>] # < typeparam extends
  956. ) |
  957. # arrow function possible to detect only with => on same line
  958. (
  959. (<\s*([_$[:alpha:]]|(\{[^\{\}]*\})|(\([^\(\)]*\))|(\[[^\[\]]*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{[^\{\}]*\})|(\([^\(\)]*\))|(\[[^\[\]]*\]))([^=<>]|=[^<])*\>)*>\s*)? # typeparameters
  960. \(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[^()]*)?\))*)?\) # parameteres
  961. (\s*:\s*([^<>\(\)]|\<[^<>]+\>|\([^\(\)]+\))+)? # return type
  962. \s*=> # arrow operator
  963. )
  964. ))
  965. ))
  966. captures:
  967. 1: punctuation.accessor.ts
  968. 2: punctuation.accessor.optional.ts
  969. 3: entity.name.function.ts
  970. - match: '(?:(\.)|(\?\.(?!\s*[[:digit:]])))\s*([[:upper:]][_$[:digit:][:upper:]]*)(?![_$[:alnum:]])'
  971. captures:
  972. 1: punctuation.accessor.ts
  973. 2: punctuation.accessor.optional.ts
  974. 3: variable.other.constant.property.ts
  975. - match: '(?:(\.)|(\?\.(?!\s*[[:digit:]])))\s*([_$[:alpha:]][_$[:alnum:]]*)'
  976. captures:
  977. 1: punctuation.accessor.ts
  978. 2: punctuation.accessor.optional.ts
  979. 3: variable.other.property.ts
  980. - match: "([[:upper:]][_$[:digit:][:upper:]]*)(?![_$[:alnum:]])"
  981. scope: variable.other.constant.ts
  982. - match: "[_$[:alpha:]][_$[:alnum:]]*"
  983. scope: variable.other.readwrite.ts
  984. import-declaration:
  985. - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(\bexport)\s+)?\b(import)(?!\s*[:\(])(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))'
  986. captures:
  987. 1: keyword.control.export.ts
  988. 2: keyword.control.import.ts
  989. push:
  990. - meta_scope: meta.import.ts
  991. - match: (?=;|$|^)
  992. pop: true
  993. - include: import-export-declaration
  994. import-equals-declaration:
  995. - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(\bexport)\s+)?\b(import)\s+([_$[:alpha:]][_$[:alnum:]]*)\s*(=)\s*(require)\s*(\()'
  996. captures:
  997. 1: keyword.control.export.ts
  998. 2: keyword.control.import.ts
  999. 3: variable.other.readwrite.alias.ts
  1000. 4: keyword.operator.assignment.ts
  1001. 5: keyword.control.require.ts
  1002. 6: meta.brace.round.ts
  1003. push:
  1004. - meta_scope: meta.import-equals.external.ts
  1005. - match: \)
  1006. captures:
  1007. 0: meta.brace.round.ts
  1008. pop: true
  1009. - include: comment
  1010. - include: string
  1011. - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(\bexport)\s+)?\b(import)\s+([_$[:alpha:]][_$[:alnum:]]*)\s*(=)\s*(?!require\b)'
  1012. captures:
  1013. 1: keyword.control.export.ts
  1014. 2: keyword.control.import.ts
  1015. 3: variable.other.readwrite.alias.ts
  1016. 4: keyword.operator.assignment.ts
  1017. push:
  1018. - meta_scope: meta.import-equals.internal.ts
  1019. - match: (?=;|$|^)
  1020. pop: true
  1021. - include: comment
  1022. - match: '([_$[:alpha:]][_$[:alnum:]]*)\s*(?:(\.)|(\?\.(?!\s*[[:digit:]])))'
  1023. captures:
  1024. 1: entity.name.type.module.ts
  1025. 2: punctuation.accessor.ts
  1026. 3: punctuation.accessor.optional.ts
  1027. - match: "([_$[:alpha:]][_$[:alnum:]]*)"
  1028. scope: variable.other.readwrite.ts
  1029. import-export-block:
  1030. - match: '\{'
  1031. captures:
  1032. 0: punctuation.definition.block.ts
  1033. push:
  1034. - meta_scope: meta.block.ts
  1035. - match: '\}'
  1036. captures:
  1037. 0: punctuation.definition.block.ts
  1038. pop: true
  1039. - include: import-export-clause
  1040. import-export-clause:
  1041. - include: comment
  1042. - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(\bdefault)|(\*)|(\b[_$[:alpha:]][_$[:alnum:]]*))\s+(as)\s+(\b[_$[:alpha:]][_$[:alnum:]]*)'
  1043. captures:
  1044. 1: keyword.control.default.ts
  1045. 2: constant.language.import-export-all.ts
  1046. 3: variable.other.readwrite.ts
  1047. 4: keyword.control.as.ts
  1048. 5: variable.other.readwrite.alias.ts
  1049. - include: punctuation-comma
  1050. - match: \*
  1051. scope: constant.language.import-export-all.ts
  1052. - match: \b(default)\b
  1053. scope: keyword.control.default.ts
  1054. - match: "([_$[:alpha:]][_$[:alnum:]]*)"
  1055. scope: variable.other.readwrite.alias.ts
  1056. import-export-declaration:
  1057. - include: comment
  1058. - include: string
  1059. - include: import-export-block
  1060. - match: \bfrom\b
  1061. scope: keyword.control.from.ts
  1062. - include: import-export-clause
  1063. indexer-declaration:
  1064. - match: '(?:(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(readonly)\s*)?(\[)\s*([_$[:alpha:]][_$[:alnum:]]*)\s*(?=:)'
  1065. captures:
  1066. 1: storage.modifier.ts
  1067. 2: meta.brace.square.ts
  1068. 3: variable.parameter.ts
  1069. push:
  1070. - meta_scope: meta.indexer.declaration.ts
  1071. - match: '(\])\s*(\?\s*)?|$'
  1072. captures:
  1073. 1: meta.brace.square.ts
  1074. 2: keyword.operator.optional.ts
  1075. pop: true
  1076. - include: type-annotation
  1077. indexer-mapped-type-declaration:
  1078. - match: '(?:(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(readonly)\s*)?(\[)\s*([_$[:alpha:]][_$[:alnum:]]*)\s+(in)\s+'
  1079. captures:
  1080. 1: storage.modifier.ts
  1081. 2: meta.brace.square.ts
  1082. 3: entity.name.type.ts
  1083. 4: keyword.operator.expression.in.ts
  1084. push:
  1085. - meta_scope: meta.indexer.mappedtype.declaration.ts
  1086. - match: '(\])\s*(\?\s*)?|$'
  1087. captures:
  1088. 1: meta.brace.square.ts
  1089. 2: keyword.operator.optional.ts
  1090. pop: true
  1091. - include: type
  1092. inline-tags:
  1093. - match: '(\[)[^\]]+(\])(?={@(?:link|linkcode|linkplain|tutorial))'
  1094. scope: constant.other.description.jsdoc
  1095. captures:
  1096. 1: punctuation.definition.bracket.square.begin.jsdoc
  1097. 2: punctuation.definition.bracket.square.end.jsdoc
  1098. - match: '({)((@)(?:link(?:code|plain)?|tutorial))\s*'
  1099. captures:
  1100. 1: punctuation.definition.bracket.curly.begin.jsdoc
  1101. 2: storage.type.class.jsdoc
  1102. 3: punctuation.definition.inline.tag.jsdoc
  1103. push:
  1104. - meta_scope: entity.name.type.instance.jsdoc
  1105. - match: '}|(?=\*/)'
  1106. captures:
  1107. 0: punctuation.definition.bracket.curly.end.jsdoc
  1108. pop: true
  1109. - match: '\G((?=https?://)(?:[^|}\s*]|\*[/])+)(\|)?'
  1110. captures:
  1111. 1: variable.other.link.underline.jsdoc
  1112. 2: punctuation.separator.pipe.jsdoc
  1113. - match: '\G((?:[^{}@\s|*]|\*[^/])+)(\|)?'
  1114. captures:
  1115. 1: variable.other.description.jsdoc
  1116. 2: punctuation.separator.pipe.jsdoc
  1117. interface-declaration:
  1118. - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(export)\s+)?\b(?:(abstract)\s+)?\b(interface)\b(?=\s+|/[/*])'
  1119. captures:
  1120. 1: keyword.control.export.ts
  1121. 2: storage.modifier.ts
  1122. 3: storage.type.interface.ts
  1123. push:
  1124. - meta_scope: meta.interface.ts
  1125. - match: '(?<=\})'
  1126. pop: true
  1127. - include: comment
  1128. - include: class-or-interface-heritage
  1129. - match: "[_$[:alpha:]][_$[:alnum:]]*"
  1130. captures:
  1131. 0: entity.name.type.interface.ts
  1132. - include: type-parameters
  1133. - include: class-or-interface-body
  1134. jsdoctype:
  1135. - match: '\G{(?:[^}*]|\*[^/}])+$'
  1136. scope: invalid.illegal.type.jsdoc
  1137. - match: '\G({)'
  1138. captures:
  1139. 0: entity.name.type.instance.jsdoc
  1140. 1: punctuation.definition.bracket.curly.begin.jsdoc
  1141. push:
  1142. - meta_content_scope: entity.name.type.instance.jsdoc
  1143. - match: '((}))\s*|(?=\*/)'
  1144. captures:
  1145. 1: entity.name.type.instance.jsdoc
  1146. 2: punctuation.definition.bracket.curly.end.jsdoc
  1147. pop: true
  1148. - include: brackets
  1149. literal:
  1150. - include: numeric-literal
  1151. - include: boolean-literal
  1152. - include: null-literal
  1153. - include: undefined-literal
  1154. - include: numericConstant-literal
  1155. - include: array-literal
  1156. - include: this-literal
  1157. - include: super-literal
  1158. method-declaration:
  1159. - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:\b(public|private|protected)\s+)?(?:\b(abstract)\s+)?(?:\b(async)\s+)?(?:\b(get|set)\s+)(?:(\*)\s*)?(?=((([_$[:alpha:]][_$[:alnum:]]*)|(\''([^\''\\]|\\\''|\\)*\'')|(\"([^\"\\]|\\\"|\\)*\")|(\[([^\[\]]|\[[^\[\]]*\])+\]))\s*(\??))\s*[\(\<])'
  1160. captures:
  1161. 1: storage.modifier.ts
  1162. 2: storage.modifier.ts
  1163. 3: storage.modifier.async.ts
  1164. 4: storage.type.property.ts
  1165. 5: keyword.generator.asterisk.ts
  1166. push:
  1167. - meta_scope: meta.method.declaration.ts
  1168. - match: '(?=\}|;|,|$)|(?<=\})'
  1169. pop: true
  1170. - include: method-declaration-name
  1171. - include: function-body
  1172. - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:\b(public|private|protected)\s+)?(?:\b(abstract)\s+)?(?:\b(async)\s+)?(?:(?:\b(?:(new)|(constructor))\b(?!:)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.)))|(?:(\*)\s*)?(?=((([_$[:alpha:]][_$[:alnum:]]*)|(\''([^\''\\]|\\\''|\\)*\'')|(\"([^\"\\]|\\\"|\\)*\")|(\[([^\[\]]|\[[^\[\]]*\])+\]))\s*(\??))?\s*[\(\<]))'
  1173. captures:
  1174. 1: storage.modifier.ts
  1175. 2: storage.modifier.ts
  1176. 3: storage.modifier.async.ts
  1177. 4: keyword.operator.new.ts
  1178. 5: storage.type.ts
  1179. 6: keyword.generator.asterisk.ts
  1180. push:
  1181. - meta_scope: meta.method.declaration.ts
  1182. - match: '(?=\}|;|,|$)|(?<=\})'
  1183. pop: true
  1184. - include: method-declaration-name
  1185. - include: function-body
  1186. method-declaration-name:
  1187. - match: '(?=(([_$[:alpha:]][_$[:alnum:]]*)|(\''([^\''\\]|\\\''|\\)*\'')|(\"([^\"\\]|\\\"|\\)*\")|(\[([^\[\]]|\[[^\[\]]*\])+\]))\s*(\??)\s*[\(\<])'
  1188. push:
  1189. - match: (?=\(|\<)
  1190. pop: true
  1191. - include: string
  1192. - include: array-literal
  1193. - match: "[_$[:alpha:]][_$[:alnum:]]*"
  1194. scope: meta.definition.method.ts entity.name.function.ts
  1195. - match: \?
  1196. scope: keyword.operator.optional.ts
  1197. namespace-declaration:
  1198. - match: '(?:(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(\bexport)\s+)?\b(namespace|module)\s+(?=[_$[:alpha:]"''`]))'
  1199. captures:
  1200. 1: keyword.control.export.ts
  1201. 2: storage.type.namespace.ts
  1202. push:
  1203. - meta_scope: meta.namespace.declaration.ts
  1204. - match: '(?<=\})|(?=;|\babstract\b|\basync\b|\bclass\b|\bconst\b|\bdeclare\b|\benum\b|\bexport\b|\bfunction\b|\bimport\b|\binterface\b|\blet\b|\bmodule\b|\bnamespace\b|\btype\b|\bvar\b)'
  1205. pop: true
  1206. - include: comment
  1207. - include: string
  1208. - match: "([_$[:alpha:]][_$[:alnum:]]*)"
  1209. scope: entity.name.type.module.ts
  1210. - include: punctuation-accessor
  1211. - include: decl-block
  1212. new-expr:
  1213. - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(new)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))'
  1214. captures:
  1215. 1: keyword.operator.new.ts
  1216. push:
  1217. - meta_scope: new.expr.ts
  1218. - match: '(?<=\))|(?=[;),}\]]|$|((?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))new(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.)))|((?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))function((\s+[_$[:alpha:]][_$[:alnum:]]*)|(\s*[\(]))))'
  1219. pop: true
  1220. - include: paren-expression
  1221. - include: class-declaration
  1222. - include: type
  1223. null-literal:
  1224. - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))null(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))'
  1225. scope: constant.language.null.ts
  1226. numeric-literal:
  1227. - match: '\b(?<!\$)0(x|X)[0-9a-fA-F]+\b(?!\$)'
  1228. scope: constant.numeric.hex.ts
  1229. - match: '\b(?<!\$)0(b|B)[01]+\b(?!\$)'
  1230. scope: constant.numeric.binary.ts
  1231. - match: '\b(?<!\$)0(o|O)?[0-7]+\b(?!\$)'
  1232. scope: constant.numeric.octal.ts
  1233. - match: |-
  1234. (?x)
  1235. (?<!\$)(?:
  1236. (?:\b[0-9]+(\.)[0-9]+[eE][+-]?[0-9]+\b)| # 1.1E+3
  1237. (?:\b[0-9]+(\.)[eE][+-]?[0-9]+\b)| # 1.E+3
  1238. (?:\B(\.)[0-9]+[eE][+-]?[0-9]+\b)| # .1E+3
  1239. (?:\b[0-9]+[eE][+-]?[0-9]+\b)| # 1E+3
  1240. (?:\b[0-9]+(\.)[0-9]+\b)| # 1.1
  1241. (?:\b[0-9]+(\.)\B)| # 1.
  1242. (?:\B(\.)[0-9]+\b)| # .1
  1243. (?:\b[0-9]+\b(?!\.)) # 1
  1244. )(?!\$)
  1245. captures:
  1246. 0: constant.numeric.decimal.ts
  1247. 1: meta.delimiter.decimal.period.ts
  1248. 2: meta.delimiter.decimal.period.ts
  1249. 3: meta.delimiter.decimal.period.ts
  1250. 4: meta.delimiter.decimal.period.ts
  1251. 5: meta.delimiter.decimal.period.ts
  1252. 6: meta.delimiter.decimal.period.ts
  1253. numericConstant-literal:
  1254. - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))NaN(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))'
  1255. scope: constant.language.nan.ts
  1256. - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))Infinity(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))'
  1257. scope: constant.language.infinity.ts
  1258. object-binding-element:
  1259. - include: comment
  1260. - match: '(?=(([_$[:alpha:]][_$[:alnum:]]*)|(\''([^\''\\]|\\\''|\\)*\'')|(\"([^\"\\]|\\\"|\\)*\")|(\[([^\[\]]|\[[^\[\]]*\])+\]))\s*(:))'
  1261. push:
  1262. - match: '(?=,|\})'
  1263. pop: true
  1264. - include: object-binding-element-propertyName
  1265. - include: binding-element
  1266. - include: object-binding-pattern
  1267. - include: destructuring-variable-rest
  1268. - include: variable-initializer
  1269. - include: punctuation-comma
  1270. object-binding-element-propertyName:
  1271. - match: '(?=(([_$[:alpha:]][_$[:alnum:]]*)|(\''([^\''\\]|\\\''|\\)*\'')|(\"([^\"\\]|\\\"|\\)*\")|(\[([^\[\]]|\[[^\[\]]*\])+\]))\s*(:))'
  1272. push:
  1273. - match: (:)
  1274. captures:
  1275. 0: punctuation.destructuring.ts
  1276. pop: true
  1277. - include: string
  1278. - include: array-literal
  1279. - match: "([_$[:alpha:]][_$[:alnum:]]*)"
  1280. scope: variable.object.property.ts
  1281. object-binding-pattern:
  1282. - match: '(?:(\.\.\.)\s*)?(\{)'
  1283. captures:
  1284. 1: keyword.operator.rest.ts
  1285. 2: punctuation.definition.binding-pattern.object.ts
  1286. push:
  1287. - match: '\}'
  1288. captures:
  1289. 0: punctuation.definition.binding-pattern.object.ts
  1290. pop: true
  1291. - include: object-binding-element
  1292. object-identifiers:
  1293. - match: '([_$[:alpha:]][_$[:alnum:]]*)(?=\s*\??\.\s*prototype\b(?!\$))'
  1294. scope: support.class.ts
  1295. - match: |-
  1296. (?x)(?:(\.)|(\?\.(?!\s*[[:digit:]])))\s*(?:
  1297. ([[:upper:]][_$[:digit:][:upper:]]*) |
  1298. ([_$[:alpha:]][_$[:alnum:]]*)
  1299. )(?=\s*\??\.\s*[_$[:alpha:]][_$[:alnum:]]*)
  1300. captures:
  1301. 1: punctuation.accessor.ts
  1302. 2: punctuation.accessor.optional.ts
  1303. 3: variable.other.constant.object.property.ts
  1304. 4: variable.other.object.property.ts
  1305. - match: |-
  1306. (?x)(?:
  1307. ([[:upper:]][_$[:digit:][:upper:]]*) |
  1308. ([_$[:alpha:]][_$[:alnum:]]*)
  1309. )(?=\s*\??\.\s*[_$[:alpha:]][_$[:alnum:]]*)
  1310. captures:
  1311. 1: variable.other.constant.object.ts
  1312. 2: variable.other.object.ts
  1313. object-literal:
  1314. - match: '\{'
  1315. captures:
  1316. 0: punctuation.definition.block.ts
  1317. push:
  1318. - meta_scope: meta.objectliteral.ts
  1319. - match: '\}'
  1320. captures:
  1321. 0: punctuation.definition.block.ts
  1322. pop: true
  1323. - include: object-member
  1324. object-literal-method-declaration:
  1325. - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:\b(async)\s+)?(?:\b(get|set)\s+)?(?:(\*)\s*)?(?=((([_$[:alpha:]][_$[:alnum:]]*)|(\''([^\''\\]|\\\''|\\)*\'')|(\"([^\"\\]|\\\"|\\)*\")|(\[([^\[\]]|\[[^\[\]]*\])+\]))\s*(\??))\s*[\(\<])'
  1326. captures:
  1327. 1: storage.modifier.async.ts
  1328. 2: storage.type.property.ts
  1329. 3: keyword.generator.asterisk.ts
  1330. push:
  1331. - meta_scope: meta.method.declaration.ts
  1332. - match: '(?=\}|;|,)|(?<=\})'
  1333. pop: true
  1334. - include: method-declaration-name
  1335. - include: function-body
  1336. - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:\b(async)\s+)?(?:\b(get|set)\s+)?(?:(\*)\s*)?(?=((([_$[:alpha:]][_$[:alnum:]]*)|(\''([^\''\\]|\\\''|\\)*\'')|(\"([^\"\\]|\\\"|\\)*\")|(\[([^\[\]]|\[[^\[\]]*\])+\]))\s*(\??))\s*[\(\<])'
  1337. captures:
  1338. 1: storage.modifier.async.ts
  1339. 2: storage.type.property.ts
  1340. 3: keyword.generator.asterisk.ts
  1341. push:
  1342. - match: (?=\(|\<)
  1343. pop: true
  1344. - include: method-declaration-name
  1345. object-member:
  1346. - include: comment
  1347. - include: object-literal-method-declaration
  1348. - match: '(?=\[)'
  1349. push:
  1350. - meta_scope: meta.object.member.ts meta.object-literal.key.ts
  1351. - match: (?=:)
  1352. pop: true
  1353. - include: array-literal
  1354. - match: '(?=[\''\"])'
  1355. push:
  1356. - meta_scope: meta.object.member.ts meta.object-literal.key.ts
  1357. - match: (?=:)
  1358. pop: true
  1359. - include: string
  1360. - match: '(?![_$[:alpha:]])([[:digit:]]+)\s*(?=:)'
  1361. scope: meta.object.member.ts
  1362. captures:
  1363. 0: meta.object-literal.key.ts
  1364. 1: constant.numeric.decimal.ts
  1365. - match: |-
  1366. (?x)(?:([_$[:alpha:]][_$[:alnum:]]*)\s*(?=:\s*(
  1367. ((async\s+)?(
  1368. (function\s*[(<*]) |
  1369. (function\s+) |
  1370. ([_$[:alpha:]][_$[:alnum:]]*\s*=>)
  1371. )) |
  1372. ((async\s*)?(
  1373. # sure shot arrow functions even if => is on new line
  1374. (
  1375. [(]\s*
  1376. (
  1377. ([)]\s*:) | # ():
  1378. ((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param:
  1379. )
  1380. ) |
  1381. (
  1382. [<]\s*[_$[:alpha:]][_$[:alnum:]]*\s+extends\s*[^=>] # < typeparam extends
  1383. ) |
  1384. # arrow function possible to detect only with => on same line
  1385. (
  1386. (<\s*([_$[:alpha:]]|(\{[^\{\}]*\})|(\([^\(\)]*\))|(\[[^\[\]]*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{[^\{\}]*\})|(\([^\(\)]*\))|(\[[^\[\]]*\]))([^=<>]|=[^<])*\>)*>\s*)? # typeparameters
  1387. \(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[^()]*)?\))*)?\) # parameteres
  1388. (\s*:\s*([^<>\(\)]|\<[^<>]+\>|\([^\(\)]+\))+)? # return type
  1389. \s*=> # arrow operator
  1390. )
  1391. ))
  1392. )))
  1393. scope: meta.object.member.ts
  1394. captures:
  1395. 0: meta.object-literal.key.ts
  1396. 1: entity.name.function.ts
  1397. - match: '(?:[_$[:alpha:]][_$[:alnum:]]*)\s*(?=:)'
  1398. scope: meta.object.member.ts
  1399. captures:
  1400. 0: meta.object-literal.key.ts
  1401. - match: \.\.\.
  1402. captures:
  1403. 0: keyword.operator.spread.ts
  1404. push:
  1405. - meta_scope: meta.object.member.ts
  1406. - match: '(?=,|\})'
  1407. pop: true
  1408. - include: expression
  1409. - match: '([_$[:alpha:]][_$[:alnum:]]*)\s*(?=,|\}|$)'
  1410. scope: meta.object.member.ts
  1411. captures:
  1412. 1: variable.other.readwrite.ts
  1413. - match: '(?=[_$[:alpha:]][_$[:alnum:]]*\s*=)'
  1414. push:
  1415. - meta_scope: meta.object.member.ts
  1416. - match: '(?=,|\}|$)'
  1417. pop: true
  1418. - include: expression
  1419. - match: ":"
  1420. captures:
  1421. 0: meta.object-literal.key.ts punctuation.separator.key-value.ts
  1422. push:
  1423. - meta_scope: meta.object.member.ts
  1424. - match: '(?=,|\})'
  1425. pop: true
  1426. - include: expression
  1427. - include: punctuation-comma
  1428. parameter-array-binding-pattern:
  1429. - match: '(?:(\.\.\.)\s*)?(\[)'
  1430. captures:
  1431. 1: keyword.operator.rest.ts
  1432. 2: punctuation.definition.binding-pattern.array.ts
  1433. push:
  1434. - match: '\]'
  1435. captures:
  1436. 0: punctuation.definition.binding-pattern.array.ts
  1437. pop: true
  1438. - include: parameter-binding-element
  1439. - include: punctuation-comma
  1440. parameter-binding-element:
  1441. - include: comment
  1442. - include: parameter-object-binding-pattern
  1443. - include: parameter-array-binding-pattern
  1444. - include: destructuring-parameter-rest
  1445. - include: variable-initializer
  1446. parameter-name:
  1447. - match: \s*\b(public|protected|private|readonly)(?=\s+(public|protected|private|readonly)\s+)
  1448. captures:
  1449. 1: storage.modifier.ts
  1450. - match: |-
  1451. (?x)(?:\s*\b(public|private|protected|readonly)\s+)?(\.\.\.)?\s*(?<!=|:)(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(this)|([_$[:alpha:]][_$[:alnum:]]*))(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))\s*(\??)(?=\s*
  1452. # function assignment |
  1453. (=\s*(
  1454. ((async\s+)?(
  1455. (function\s*[(<*]) |
  1456. (function\s+) |
  1457. ([_$[:alpha:]][_$[:alnum:]]*\s*=>)
  1458. )) |
  1459. ((async\s*)?(
  1460. # sure shot arrow functions even if => is on new line
  1461. (
  1462. [(]\s*
  1463. (
  1464. ([)]\s*:) | # ():
  1465. ((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param:
  1466. )
  1467. ) |
  1468. (
  1469. [<]\s*[_$[:alpha:]][_$[:alnum:]]*\s+extends\s*[^=>] # < typeparam extends
  1470. ) |
  1471. # arrow function possible to detect only with => on same line
  1472. (
  1473. (<\s*([_$[:alpha:]]|(\{[^\{\}]*\})|(\([^\(\)]*\))|(\[[^\[\]]*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{[^\{\}]*\})|(\([^\(\)]*\))|(\[[^\[\]]*\]))([^=<>]|=[^<])*\>)*>\s*)? # typeparameters
  1474. \(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[^()]*)?\))*)?\) # parameteres
  1475. (\s*:\s*([^<>\(\)]|\<[^<>]+\>|\([^\(\)]+\))+)? # return type
  1476. \s*=> # arrow operator
  1477. )
  1478. ))
  1479. )) |
  1480. # typeannotation is fn type: < | () | (... | (param: | (param, | (param? | (param= | (param) =>
  1481. (:\s*(
  1482. (<) |
  1483. ([(]\s*(
  1484. ([)]) |
  1485. (\.\.\.) |
  1486. ([_$[:alnum:]]+\s*(
  1487. ([:,?=])|
  1488. ([)]\s*=>)
  1489. ))
  1490. ))
  1491. )))
  1492. captures:
  1493. 1: storage.modifier.ts
  1494. 2: keyword.operator.rest.ts
  1495. 3: entity.name.function.ts variable.language.this.ts
  1496. 4: entity.name.function.ts
  1497. 5: keyword.operator.optional.ts
  1498. - match: '(?x)(?:\s*\b(public|private|protected|readonly)\s+)?(\.\.\.)?\s*(?<!=|:)(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(this)|([_$[:alpha:]][_$[:alnum:]]*))(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))\s*(\??)'
  1499. captures:
  1500. 1: storage.modifier.ts
  1501. 2: keyword.operator.rest.ts
  1502. 3: variable.parameter.ts variable.language.this.ts
  1503. 4: variable.parameter.ts
  1504. 5: keyword.operator.optional.ts
  1505. parameter-object-binding-element:
  1506. - include: comment
  1507. - match: '(?=(([_$[:alpha:]][_$[:alnum:]]*)|(\''([^\''\\]|\\\''|\\)*\'')|(\"([^\"\\]|\\\"|\\)*\")|(\[([^\[\]]|\[[^\[\]]*\])+\]))\s*(:))'
  1508. push:
  1509. - match: '(?=,|\})'
  1510. pop: true
  1511. - include: object-binding-element-propertyName
  1512. - include: parameter-binding-element
  1513. - include: parameter-object-binding-pattern
  1514. - include: destructuring-parameter-rest
  1515. - include: variable-initializer
  1516. - include: punctuation-comma
  1517. parameter-object-binding-pattern:
  1518. - match: '(?:(\.\.\.)\s*)?(\{)'
  1519. captures:
  1520. 1: keyword.operator.rest.ts
  1521. 2: punctuation.definition.binding-pattern.object.ts
  1522. push:
  1523. - match: '\}'
  1524. captures:
  1525. 0: punctuation.definition.binding-pattern.object.ts
  1526. pop: true
  1527. - include: parameter-object-binding-element
  1528. paren-expression:
  1529. - match: \(
  1530. captures:
  1531. 0: meta.brace.round.ts
  1532. push:
  1533. - match: \)
  1534. captures:
  1535. 0: meta.brace.round.ts
  1536. pop: true
  1537. - include: expression
  1538. - include: punctuation-comma
  1539. property-accessor:
  1540. - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(get|set)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))'
  1541. scope: storage.type.property.ts
  1542. punctuation-accessor:
  1543. - match: '(?:(\.)|(\?\.(?!\s*[[:digit:]])))'
  1544. captures:
  1545. 1: punctuation.accessor.ts
  1546. 2: punctuation.accessor.optional.ts
  1547. punctuation-comma:
  1548. - match: ","
  1549. scope: punctuation.separator.comma.ts
  1550. punctuation-semicolon:
  1551. - match: ;
  1552. scope: punctuation.terminator.statement.ts
  1553. qstring-double:
  1554. - match: '"'
  1555. captures:
  1556. 0: punctuation.definition.string.begin.ts
  1557. push:
  1558. - meta_scope: string.quoted.double.ts
  1559. - match: '(")|((?:[^\\\n])$)'
  1560. captures:
  1561. 1: punctuation.definition.string.end.ts
  1562. 2: invalid.illegal.newline.ts
  1563. pop: true
  1564. - include: string-character-escape
  1565. qstring-single:
  1566. - match: "'"
  1567. captures:
  1568. 0: punctuation.definition.string.begin.ts
  1569. push:
  1570. - meta_scope: string.quoted.single.ts
  1571. - match: '(\'')|((?:[^\\\n])$)'
  1572. captures:
  1573. 1: punctuation.definition.string.end.ts
  1574. 2: invalid.illegal.newline.ts
  1575. pop: true
  1576. - include: string-character-escape
  1577. regex:
  1578. - match: '(?<=[=(:,\[?+!]|return|case|=>|&&|\|\||\*\/)\s*(\/)(?![\/*])(?=(?:[^\/\\\[]|\\.|\[([^\]\\]|\\.)+\])+\/(?![\/*])[gimuy]*(?!\s*[a-zA-Z0-9_$]))'
  1579. captures:
  1580. 1: punctuation.definition.string.begin.ts
  1581. push:
  1582. - meta_scope: string.regexp.ts
  1583. - match: "(/)([gimuy]*)"
  1584. captures:
  1585. 1: punctuation.definition.string.end.ts
  1586. 2: keyword.other.ts
  1587. pop: true
  1588. - include: regexp
  1589. - match: '(?<![_$[:alnum:])])\/(?![\/*])(?=(?:[^\/\\\[]|\\.|\[([^\]\\]|\\.)+\])+\/(?![\/*])[gimuy]*(?!\s*[a-zA-Z0-9_$]))'
  1590. captures:
  1591. 0: punctuation.definition.string.begin.ts
  1592. push:
  1593. - meta_scope: string.regexp.ts
  1594. - match: "(/)([gimuy]*)"
  1595. captures:
  1596. 1: punctuation.definition.string.end.ts
  1597. 2: keyword.other.ts
  1598. pop: true
  1599. - include: regexp
  1600. regex-character-class:
  1601. - match: '\\[wWsSdDtrnvf]|\.'
  1602. scope: constant.other.character-class.regexp
  1603. - match: '\\([0-7]{3}|x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4})'
  1604. scope: constant.character.numeric.regexp
  1605. - match: '\\c[A-Z]'
  1606. scope: constant.character.control.regexp
  1607. - match: \\.
  1608. scope: constant.character.escape.backslash.regexp
  1609. regexp:
  1610. - match: '\\[bB]|\^|\$'
  1611. scope: keyword.control.anchor.regexp
  1612. - match: '\\[1-9]\d*'
  1613. scope: keyword.other.back-reference.regexp
  1614. - match: '[?+*]|\{(\d+,\d+|\d+,|,\d+|\d+)\}\??'
  1615. scope: keyword.operator.quantifier.regexp
  1616. - match: \|
  1617. scope: keyword.operator.or.regexp
  1618. - match: (\()((\?=)|(\?!))
  1619. captures:
  1620. 1: punctuation.definition.group.regexp
  1621. 2: punctuation.definition.group.assertion.regexp
  1622. 3: meta.assertion.look-ahead.regexp
  1623. 4: meta.assertion.negative-look-ahead.regexp
  1624. push:
  1625. - meta_scope: meta.group.assertion.regexp
  1626. - match: (\))
  1627. captures:
  1628. 1: punctuation.definition.group.regexp
  1629. pop: true
  1630. - include: regexp
  1631. - match: \((\?:)?
  1632. captures:
  1633. 0: punctuation.definition.group.regexp
  1634. 1: punctuation.definition.group.no-capture.regexp
  1635. push:
  1636. - meta_scope: meta.group.regexp
  1637. - match: \)
  1638. captures:
  1639. 0: punctuation.definition.group.regexp
  1640. pop: true
  1641. - include: regexp
  1642. - match: '(\[)(\^)?'
  1643. captures:
  1644. 1: punctuation.definition.character-class.regexp
  1645. 2: keyword.operator.negation.regexp
  1646. push:
  1647. - meta_scope: constant.other.character-class.set.regexp
  1648. - match: '(\])'
  1649. captures:
  1650. 1: punctuation.definition.character-class.regexp
  1651. pop: true
  1652. - match: '(?:.|(\\(?:[0-7]{3}|x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}))|(\\c[A-Z])|(\\.))\-(?:[^\]\\]|(\\(?:[0-7]{3}|x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}))|(\\c[A-Z])|(\\.))'
  1653. scope: constant.other.character-class.range.regexp
  1654. captures:
  1655. 1: constant.character.numeric.regexp
  1656. 2: constant.character.control.regexp
  1657. 3: constant.character.escape.backslash.regexp
  1658. 4: constant.character.numeric.regexp
  1659. 5: constant.character.control.regexp
  1660. 6: constant.character.escape.backslash.regexp
  1661. - include: regex-character-class
  1662. - include: regex-character-class
  1663. return-type:
  1664. - match: (?<=\))\s*(:)(?=\s*\S)
  1665. captures:
  1666. 1: keyword.operator.type.annotation.ts
  1667. push:
  1668. - meta_scope: meta.return.type.ts
  1669. - match: "(?<![:|&])(?=$|^|[{};,]|//)"
  1670. pop: true
  1671. - include: return-type-core
  1672. - match: (?<=\))\s*(:)
  1673. captures:
  1674. 1: keyword.operator.type.annotation.ts
  1675. push:
  1676. - meta_scope: meta.return.type.ts
  1677. - match: '(?<![:|&])((?=[{};,]|//|^\s*$)|((?<=\S)(?=\s*$)))'
  1678. pop: true
  1679. - include: return-type-core
  1680. return-type-core:
  1681. - include: comment
  1682. - match: '(?<=[:|&])(?=\s*\{)'
  1683. push:
  1684. - match: '(?<=\})'
  1685. pop: true
  1686. - include: type-object
  1687. - include: type-predicate-operator
  1688. - include: type
  1689. statements:
  1690. - include: string
  1691. - include: template
  1692. - include: comment
  1693. - include: declaration
  1694. - include: control-statement
  1695. - include: after-operator-block-as-object-literal
  1696. - include: decl-block
  1697. - include: expression
  1698. - include: punctuation-semicolon
  1699. string:
  1700. - include: qstring-single
  1701. - include: qstring-double
  1702. string-character-escape:
  1703. - match: '\\(x[0-9A-Fa-f]{2}|[0-2][0-7]{0,2}|3[0-6][0-7]?|37[0-7]?|[4-7][0-7]?|.|$)'
  1704. scope: constant.character.escape.ts
  1705. super-literal:
  1706. - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))super\b(?!\$)'
  1707. scope: variable.language.super.ts
  1708. support-objects:
  1709. - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(arguments)\b(?!\$)'
  1710. scope: variable.language.arguments.ts
  1711. - match: |-
  1712. (?x)(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(Array|ArrayBuffer|Atomics|Boolean|DataView|Date|Float32Array|Float64Array|Function|Generator
  1713. |GeneratorFunction|Int8Array|Int16Array|Int32Array|Intl|Map|Number|Object|Promise|Proxy
  1714. |Reflect|RegExp|Set|SharedArrayBuffer|SIMD|String|Symbol|TypedArray
  1715. |Uint8Array|Uint16Array|Uint32Array|Uint8ClampedArray|WeakMap|WeakSet)\b(?!\$)
  1716. scope: support.class.builtin.ts
  1717. - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))((Eval|Internal|Range|Reference|Syntax|Type|URI)?Error)\b(?!\$)'
  1718. scope: support.class.error.ts
  1719. - match: |-
  1720. (?x)(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(clear(Interval|Timeout)|decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|escape|eval|
  1721. isFinite|isNaN|parseFloat|parseInt|require|set(Interval|Timeout)|super|unescape|uneval)(?=\s*\()
  1722. scope: support.function.ts
  1723. - match: |-
  1724. (?x)(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(Math)(?:\s*(?:(\.)|(\?\.(?!\s*[[:digit:]])))\s*(?:
  1725. (abs|acos|acosh|asin|asinh|atan|atan2|atanh|cbrt|ceil|clz32|cos|cosh|exp|
  1726. expm1|floor|fround|hypot|imul|log|log10|log1p|log2|max|min|pow|random|
  1727. round|sign|sin|sinh|sqrt|tan|tanh|trunc)
  1728. |
  1729. (E|LN10|LN2|LOG10E|LOG2E|PI|SQRT1_2|SQRT2)))?\b(?!\$)
  1730. captures:
  1731. 1: support.constant.math.ts
  1732. 2: punctuation.accessor.ts
  1733. 3: punctuation.accessor.optional.ts
  1734. 4: support.function.math.ts
  1735. 5: support.constant.property.math.ts
  1736. - match: |-
  1737. (?x)(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(console)(?:\s*(?:(\.)|(\?\.(?!\s*[[:digit:]])))\s*(
  1738. assert|clear|count|debug|dir|error|group|groupCollapsed|groupEnd|info|log
  1739. |profile|profileEnd|table|time|timeEnd|timeStamp|trace|warn))?\b(?!\$)
  1740. captures:
  1741. 1: support.class.console.ts
  1742. 2: punctuation.accessor.ts
  1743. 3: punctuation.accessor.optional.ts
  1744. 4: support.function.console.ts
  1745. - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(JSON)(?:\s*(?:(\.)|(\?\.(?!\s*[[:digit:]])))\s*(parse|stringify))?\b(?!\$)'
  1746. captures:
  1747. 1: support.constant.json.ts
  1748. 2: punctuation.accessor.ts
  1749. 3: punctuation.accessor.optional.ts
  1750. 4: support.function.json.ts
  1751. - match: |-
  1752. (?x) (?:(\.)|(\?\.(?!\s*[[:digit:]]))) \s* (?:
  1753. (constructor|length|prototype|__proto__)
  1754. |
  1755. (EPSILON|MAX_SAFE_INTEGER|MAX_VALUE|MIN_SAFE_INTEGER|MIN_VALUE|NEGATIVE_INFINITY|POSITIVE_INFINITY))\b(?!\$)
  1756. captures:
  1757. 1: punctuation.accessor.ts
  1758. 2: punctuation.accessor.optional.ts
  1759. 3: support.variable.property.ts
  1760. 4: support.constant.ts
  1761. - match: |-
  1762. (?x) (?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.)) \b (?:
  1763. (document|event|navigator|performance|screen|window)
  1764. |
  1765. (AnalyserNode|ArrayBufferView|Attr|AudioBuffer|AudioBufferSourceNode|AudioContext|AudioDestinationNode|AudioListener
  1766. |AudioNode|AudioParam|BatteryManager|BeforeUnloadEvent|BiquadFilterNode|Blob|BufferSource|ByteString|CSS|CSSConditionRule
  1767. |CSSCounterStyleRule|CSSGroupingRule|CSSMatrix|CSSMediaRule|CSSPageRule|CSSPrimitiveValue|CSSRule|CSSRuleList|CSSStyleDeclaration
  1768. |CSSStyleRule|CSSStyleSheet|CSSSupportsRule|CSSValue|CSSValueList|CanvasGradient|CanvasImageSource|CanvasPattern
  1769. |CanvasRenderingContext2D|ChannelMergerNode|ChannelSplitterNode|CharacterData|ChromeWorker|CloseEvent|Comment|CompositionEvent
  1770. |Console|ConvolverNode|Coordinates|Credential|CredentialsContainer|Crypto|CryptoKey|CustomEvent|DOMError|DOMException
  1771. |DOMHighResTimeStamp|DOMImplementation|DOMString|DOMStringList|DOMStringMap|DOMTimeStamp|DOMTokenList|DataTransfer
  1772. |DataTransferItem|DataTransferItemList|DedicatedWorkerGlobalScope|DelayNode|DeviceProximityEvent|DirectoryEntry
  1773. |DirectoryEntrySync|DirectoryReader|DirectoryReaderSync|Document|DocumentFragment|DocumentTouch|DocumentType|DragEvent
  1774. |DynamicsCompressorNode|Element|Entry|EntrySync|ErrorEvent|Event|EventListener|EventSource|EventTarget|FederatedCredential
  1775. |FetchEvent|File|FileEntry|FileEntrySync|FileException|FileList|FileReader|FileReaderSync|FileSystem|FileSystemSync
  1776. |FontFace|FormData|GainNode|Gamepad|GamepadButton|GamepadEvent|Geolocation|GlobalEventHandlers|HTMLAnchorElement
  1777. |HTMLAreaElement|HTMLAudioElement|HTMLBRElement|HTMLBaseElement|HTMLBodyElement|HTMLButtonElement|HTMLCanvasElement
  1778. |HTMLCollection|HTMLContentElement|HTMLDListElement|HTMLDataElement|HTMLDataListElement|HTMLDialogElement|HTMLDivElement
  1779. |HTMLDocument|HTMLElement|HTMLEmbedElement|HTMLFieldSetElement|HTMLFontElement|HTMLFormControlsCollection|HTMLFormElement
  1780. |HTMLHRElement|HTMLHeadElement|HTMLHeadingElement|HTMLHtmlElement|HTMLIFrameElement|HTMLImageElement|HTMLInputElement
  1781. |HTMLKeygenElement|HTMLLIElement|HTMLLabelElement|HTMLLegendElement|HTMLLinkElement|HTMLMapElement|HTMLMediaElement
  1782. |HTMLMetaElement|HTMLMeterElement|HTMLModElement|HTMLOListElement|HTMLObjectElement|HTMLOptGroupElement|HTMLOptionElement
  1783. |HTMLOptionsCollection|HTMLOutputElement|HTMLParagraphElement|HTMLParamElement|HTMLPreElement|HTMLProgressElement
  1784. |HTMLQuoteElement|HTMLScriptElement|HTMLSelectElement|HTMLShadowElement|HTMLSourceElement|HTMLSpanElement|HTMLStyleElement
  1785. |HTMLTableCaptionElement|HTMLTableCellElement|HTMLTableColElement|HTMLTableDataCellElement|HTMLTableElement|HTMLTableHeaderCellElement
  1786. |HTMLTableRowElement|HTMLTableSectionElement|HTMLTextAreaElement|HTMLTimeElement|HTMLTitleElement|HTMLTrackElement
  1787. |HTMLUListElement|HTMLUnknownElement|HTMLVideoElement|HashChangeEvent|History|IDBCursor|IDBCursorWithValue|IDBDatabase
  1788. |IDBEnvironment|IDBFactory|IDBIndex|IDBKeyRange|IDBMutableFile|IDBObjectStore|IDBOpenDBRequest|IDBRequest|IDBTransaction
  1789. |IDBVersionChangeEvent|IIRFilterNode|IdentityManager|ImageBitmap|ImageBitmapFactories|ImageData|Index|InputDeviceCapabilities
  1790. |InputEvent|InstallEvent|InstallTrigger|KeyboardEvent|LinkStyle|LocalFileSystem|LocalFileSystemSync|Location|MIDIAccess
  1791. |MIDIConnectionEvent|MIDIInput|MIDIInputMap|MIDIOutputMap|MediaElementAudioSourceNode|MediaError|MediaKeyMessageEvent
  1792. |MediaKeySession|MediaKeyStatusMap|MediaKeySystemAccess|MediaKeySystemConfiguration|MediaKeys|MediaRecorder|MediaStream
  1793. |MediaStreamAudioDestinationNode|MediaStreamAudioSourceNode|MessageChannel|MessageEvent|MessagePort|MouseEvent
  1794. |MutationObserver|MutationRecord|NamedNodeMap|Navigator|NavigatorConcurrentHardware|NavigatorGeolocation|NavigatorID
  1795. |NavigatorLanguage|NavigatorOnLine|Node|NodeFilter|NodeIterator|NodeList|NonDocumentTypeChildNode|Notification
  1796. |OfflineAudioCompletionEvent|OfflineAudioContext|OscillatorNode|PageTransitionEvent|PannerNode|ParentNode|PasswordCredential
  1797. |Path2D|PaymentAddress|PaymentRequest|PaymentResponse|Performance|PerformanceEntry|PerformanceFrameTiming|PerformanceMark
  1798. |PerformanceMeasure|PerformanceNavigation|PerformanceNavigationTiming|PerformanceObserver|PerformanceObserverEntryList
  1799. |PerformanceResourceTiming|PerformanceTiming|PeriodicSyncEvent|PeriodicWave|Plugin|Point|PointerEvent|PopStateEvent
  1800. |PortCollection|Position|PositionError|PositionOptions|PresentationConnectionClosedEvent|PresentationConnectionList
  1801. |PresentationReceiver|ProcessingInstruction|ProgressEvent|PromiseRejectionEvent|PushEvent|PushRegistrationManager
  1802. |RTCCertificate|RTCConfiguration|RTCPeerConnection|RTCSessionDescriptionCallback|RTCStatsReport|RadioNodeList|RandomSource
  1803. |Range|ReadableByteStream|RenderingContext|SVGAElement|SVGAngle|SVGAnimateColorElement|SVGAnimateElement|SVGAnimateMotionElement
  1804. |SVGAnimateTransformElement|SVGAnimatedAngle|SVGAnimatedBoolean|SVGAnimatedEnumeration|SVGAnimatedInteger|SVGAnimatedLength
  1805. |SVGAnimatedLengthList|SVGAnimatedNumber|SVGAnimatedNumberList|SVGAnimatedPoints|SVGAnimatedPreserveAspectRatio
  1806. |SVGAnimatedRect|SVGAnimatedString|SVGAnimatedTransformList|SVGAnimationElement|SVGCircleElement|SVGClipPathElement
  1807. |SVGCursorElement|SVGDefsElement|SVGDescElement|SVGElement|SVGEllipseElement|SVGEvent|SVGFilterElement|SVGFontElement
  1808. |SVGFontFaceElement|SVGFontFaceFormatElement|SVGFontFaceNameElement|SVGFontFaceSrcElement|SVGFontFaceUriElement
  1809. |SVGForeignObjectElement|SVGGElement|SVGGlyphElement|SVGGradientElement|SVGHKernElement|SVGImageElement|SVGLength
  1810. |SVGLengthList|SVGLineElement|SVGLinearGradientElement|SVGMPathElement|SVGMaskElement|SVGMatrix|SVGMissingGlyphElement
  1811. |SVGNumber|SVGNumberList|SVGPathElement|SVGPatternElement|SVGPoint|SVGPolygonElement|SVGPolylineElement|SVGPreserveAspectRatio
  1812. |SVGRadialGradientElement|SVGRect|SVGRectElement|SVGSVGElement|SVGScriptElement|SVGSetElement|SVGStopElement|SVGStringList
  1813. |SVGStylable|SVGStyleElement|SVGSwitchElement|SVGSymbolElement|SVGTRefElement|SVGTSpanElement|SVGTests|SVGTextElement
  1814. |SVGTextPositioningElement|SVGTitleElement|SVGTransform|SVGTransformList|SVGTransformable|SVGUseElement|SVGVKernElement
  1815. |SVGViewElement|ServiceWorker|ServiceWorkerContainer|ServiceWorkerGlobalScope|ServiceWorkerRegistration|ServiceWorkerState
  1816. |ShadowRoot|SharedWorker|SharedWorkerGlobalScope|SourceBufferList|StereoPannerNode|Storage|StorageEvent|StyleSheet
  1817. |StyleSheetList|SubtleCrypto|SyncEvent|Text|TextMetrics|TimeEvent|TimeRanges|Touch|TouchEvent|TouchList|Transferable
  1818. |TreeWalker|UIEvent|USVString|VRDisplayCapabilities|ValidityState|WaveShaperNode|WebGL|WebGLActiveInfo|WebGLBuffer
  1819. |WebGLContextEvent|WebGLFramebuffer|WebGLProgram|WebGLRenderbuffer|WebGLRenderingContext|WebGLShader|WebGLShaderPrecisionFormat
  1820. |WebGLTexture|WebGLTimerQueryEXT|WebGLTransformFeedback|WebGLUniformLocation|WebGLVertexArrayObject|WebGLVertexArrayObjectOES
  1821. |WebSocket|WebSockets|WebVTT|WheelEvent|Window|WindowBase64|WindowEventHandlers|WindowTimers|Worker|WorkerGlobalScope
  1822. |WorkerLocation|WorkerNavigator|XMLHttpRequest|XMLHttpRequestEventTarget|XMLSerializer|XPathExpression|XPathResult
  1823. |XSLTProcessor))\b(?!\$)
  1824. captures:
  1825. 1: support.variable.dom.ts
  1826. 2: support.class.dom.ts
  1827. - match: |-
  1828. (?x) (?:(\.)|(\?\.(?!\s*[[:digit:]]))) \s* (?:
  1829. (ATTRIBUTE_NODE|CDATA_SECTION_NODE|COMMENT_NODE|DOCUMENT_FRAGMENT_NODE|DOCUMENT_NODE|DOCUMENT_TYPE_NODE
  1830. |DOMSTRING_SIZE_ERR|ELEMENT_NODE|ENTITY_NODE|ENTITY_REFERENCE_NODE|HIERARCHY_REQUEST_ERR|INDEX_SIZE_ERR
  1831. |INUSE_ATTRIBUTE_ERR|INVALID_CHARACTER_ERR|NO_DATA_ALLOWED_ERR|NO_MODIFICATION_ALLOWED_ERR|NOT_FOUND_ERR
  1832. |NOT_SUPPORTED_ERR|NOTATION_NODE|PROCESSING_INSTRUCTION_NODE|TEXT_NODE|WRONG_DOCUMENT_ERR)
  1833. |
  1834. (_content|[xyz]|abbr|above|accept|acceptCharset|accessKey|action|align|[av]Link(?:color)?|all|alt|anchors|appCodeName
  1835. |appCore|applets|appMinorVersion|appName|appVersion|archive|areas|arguments|attributes|availHeight|availLeft|availTop
  1836. |availWidth|axis|background|backgroundColor|backgroundImage|below|bgColor|body|border|borderBottomWidth|borderColor
  1837. |borderLeftWidth|borderRightWidth|borderStyle|borderTopWidth|borderWidth|bottom|bufferDepth|callee|caller|caption
  1838. |cellPadding|cells|cellSpacing|ch|characterSet|charset|checked|childNodes|chOff|cite|classes|className|clear
  1839. |clientInformation|clip|clipBoardData|closed|code|codeBase|codeType|color|colorDepth|cols|colSpan|compact|complete
  1840. |components|content|controllers|cookie|cookieEnabled|cords|cpuClass|crypto|current|data|dateTime|declare|defaultCharset
  1841. |defaultChecked|defaultSelected|defaultStatus|defaultValue|defaultView|defer|description|dialogArguments|dialogHeight
  1842. |dialogLeft|dialogTop|dialogWidth|dir|directories|disabled|display|docmain|doctype|documentElement|elements|embeds
  1843. |enabledPlugin|encoding|enctype|entities|event|expando|external|face|fgColor|filename|firstChild|fontFamily|fontSize
  1844. |fontWeight|form|formName|forms|frame|frameBorder|frameElement|frames|hasFocus|hash|headers|height|history|host
  1845. |hostname|href|hreflang|hspace|htmlFor|httpEquiv|id|ids|ignoreCase|images|implementation|index|innerHeight|innerWidth
  1846. |input|isMap|label|lang|language|lastChild|lastIndex|lastMatch|lastModified|lastParen|layer[sXY]|left|leftContext
  1847. |lineHeight|link|linkColor|links|listStyleType|localName|location|locationbar|longDesc|lowsrc|lowSrc|marginBottom
  1848. |marginHeight|marginLeft|marginRight|marginTop|marginWidth|maxLength|media|menubar|method|mimeTypes|multiline|multiple
  1849. |name|nameProp|namespaces|namespaceURI|next|nextSibling|nodeName|nodeType|nodeValue|noHref|noResize|noShade|notationName
  1850. |notations|noWrap|object|offscreenBuffering|onLine|onreadystatechange|opener|opsProfile|options|oscpu|outerHeight
  1851. |outerWidth|ownerDocument|paddingBottom|paddingLeft|paddingRight|paddingTop|page[XY]|page[XY]Offset|parent|parentLayer
  1852. |parentNode|parentWindow|pathname|personalbar|pixelDepth|pkcs11|platform|plugins|port|prefix|previous|previousDibling
  1853. |product|productSub|profile|profileend|prompt|prompter|protocol|publicId|readOnly|readyState|referrer|rel|responseText
  1854. |responseXML|rev|right|rightContext|rowIndex|rows|rowSpan|rules|scheme|scope|screen[XY]|screenLeft|screenTop|scripts
  1855. |scrollbars|scrolling|sectionRowIndex|security|securityPolicy|selected|selectedIndex|selection|self|shape|siblingAbove
  1856. |siblingBelow|size|source|specified|standby|start|status|statusbar|statusText|style|styleSheets|suffixes|summary
  1857. |systemId|systemLanguage|tagName|tags|target|tBodies|text|textAlign|textDecoration|textIndent|textTransform|tFoot|tHead
  1858. |title|toolbar|top|type|undefined|uniqueID|updateInterval|URL|URLUnencoded|useMap|userAgent|userLanguage|userProfile
  1859. |vAlign|value|valueType|vendor|vendorSub|version|visibility|vspace|whiteSpace|width|X[MS]LDocument|zIndex))\b(?!\$|\s*(<\s*([_$[:alpha:]]|(\{[^\{\}]*\})|(\([^\(\)]*\))|(\[[^\[\]]*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{[^\{\}]*\})|(\([^\(\)]*\))|(\[[^\[\]]*\]))([^=<>]|=[^<])*\>)*>\s*)?\()
  1860. captures:
  1861. 1: punctuation.accessor.ts
  1862. 2: punctuation.accessor.optional.ts
  1863. 3: support.constant.dom.ts
  1864. 4: support.variable.property.dom.ts
  1865. - match: |-
  1866. (?x)(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(Buffer|EventEmitter|Server|Pipe|Socket|REPLServer|ReadStream|WriteStream|Stream
  1867. |Inflate|Deflate|InflateRaw|DeflateRaw|GZip|GUnzip|Unzip|Zip)\b(?!\$)
  1868. scope: support.class.node.ts
  1869. - match: |-
  1870. (?x)(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(process)(?:(?:(\.)|(\?\.(?!\s*[[:digit:]])))(?:
  1871. (arch|argv|config|connected|env|execArgv|execPath|exitCode|mainModule|pid|platform|release|stderr|stdin|stdout|title|version|versions)
  1872. |
  1873. (abort|chdir|cwd|disconnect|exit|[sg]ete?[gu]id|send|[sg]etgroups|initgroups|kill|memoryUsage|nextTick|umask|uptime|hrtime)
  1874. ))?\b(?!\$)
  1875. captures:
  1876. 1: support.variable.object.process.ts
  1877. 2: punctuation.accessor.ts
  1878. 3: punctuation.accessor.optional.ts
  1879. 4: support.variable.property.process.ts
  1880. 5: support.function.process.ts
  1881. - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(exports)|(module)(?:(?:(\.)|(\?\.(?!\s*[[:digit:]])))(exports|id|filename|loaded|parent|children))?)\b(?!\$)'
  1882. captures:
  1883. 1: support.type.object.module.ts
  1884. 2: support.type.object.module.ts
  1885. 3: punctuation.accessor.ts
  1886. 4: punctuation.accessor.optional.ts
  1887. 5: support.type.object.module.ts
  1888. - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(global|GLOBAL|root|__dirname|__filename)\b(?!\$)'
  1889. scope: support.variable.object.node.ts
  1890. - match: |-
  1891. (?x) (?:(\.)|(\?\.(?!\s*[[:digit:]]))) \s*
  1892. (?:
  1893. (on(?:Rowsinserted|Rowsdelete|Rowenter|Rowexit|Resize|Resizestart|Resizeend|Reset|
  1894. Readystatechange|Mouseout|Mouseover|Mousedown|Mouseup|Mousemove|
  1895. Before(?:cut|deactivate|unload|update|paste|print|editfocus|activate)|
  1896. Blur|Scrolltop|Submit|Select|Selectstart|Selectionchange|Hover|Help|
  1897. Change|Contextmenu|Controlselect|Cut|Cellchange|Clock|Close|Deactivate|
  1898. Datasetchanged|Datasetcomplete|Dataavailable|Drop|Drag|Dragstart|Dragover|
  1899. Dragdrop|Dragenter|Dragend|Dragleave|Dblclick|Unload|Paste|Propertychange|Error|
  1900. Errorupdate|Keydown|Keyup|Keypress|Focus|Load|Activate|Afterupdate|Afterprint|Abort)
  1901. ) |
  1902. (shift|showModelessDialog|showModalDialog|showHelp|scroll|scrollX|scrollByPages|
  1903. scrollByLines|scrollY|scrollTo|stop|strike|sizeToContent|sidebar|signText|sort|
  1904. sup|sub|substr|substring|splice|split|send|set(?:Milliseconds|Seconds|Minutes|Hours|
  1905. Month|Year|FullYear|Date|UTC(?:Milliseconds|Seconds|Minutes|Hours|Month|FullYear|Date)|
  1906. Time|Hotkeys|Cursor|ZOptions|Active|Resizable|RequestHeader)|search|slice|
  1907. savePreferences|small|home|handleEvent|navigate|char|charCodeAt|charAt|concat|
  1908. contextual|confirm|compile|clear|captureEvents|call|createStyleSheet|createPopup|
  1909. createEventObject|to(?:GMTString|UTCString|String|Source|UpperCase|LowerCase|LocaleString)|
  1910. test|taint|taintEnabled|indexOf|italics|disableExternalCapture|dump|detachEvent|unshift|
  1911. untaint|unwatch|updateCommands|join|javaEnabled|pop|push|plugins.refresh|paddings|parse|
  1912. print|prompt|preference|enableExternalCapture|exec|execScript|valueOf|UTC|find|file|
  1913. fileModifiedDate|fileSize|fileCreatedDate|fileUpdatedDate|fixed|fontsize|fontcolor|
  1914. forward|fromCharCode|watch|link|load|lastIndexOf|anchor|attachEvent|atob|apply|alert|
  1915. abort|routeEvents|resize|resizeBy|resizeTo|recalc|returnValue|replace|reverse|reload|
  1916. releaseCapture|releaseEvents|go|get(?:Milliseconds|Seconds|Minutes|Hours|Month|Day|Year|FullYear|
  1917. Time|Date|TimezoneOffset|UTC(?:Milliseconds|Seconds|Minutes|Hours|Day|Month|FullYear|Date)|
  1918. Attention|Selection|ResponseHeader|AllResponseHeaders)|moveBy|moveBelow|moveTo|
  1919. moveToAbsolute|moveAbove|mergeAttributes|match|margins|btoa|big|bold|borderWidths|blink|back
  1920. ) |
  1921. (acceptNode|add|addEventListener|addTextTrack|adoptNode|after|animate|append|
  1922. appendChild|appendData|before|blur|canPlayType|captureStream|
  1923. caretPositionFromPoint|caretRangeFromPoint|checkValidity|clear|click|
  1924. cloneContents|cloneNode|cloneRange|close|closest|collapse|
  1925. compareBoundaryPoints|compareDocumentPosition|comparePoint|contains|
  1926. convertPointFromNode|convertQuadFromNode|convertRectFromNode|createAttribute|
  1927. createAttributeNS|createCaption|createCDATASection|createComment|
  1928. createContextualFragment|createDocument|createDocumentFragment|
  1929. createDocumentType|createElement|createElementNS|createEntityReference|
  1930. createEvent|createExpression|createHTMLDocument|createNodeIterator|
  1931. createNSResolver|createProcessingInstruction|createRange|createShadowRoot|
  1932. createTBody|createTextNode|createTFoot|createTHead|createTreeWalker|delete|
  1933. deleteCaption|deleteCell|deleteContents|deleteData|deleteRow|deleteTFoot|
  1934. deleteTHead|detach|disconnect|dispatchEvent|elementFromPoint|elementsFromPoint|
  1935. enableStyleSheetsForSet|entries|evaluate|execCommand|exitFullscreen|
  1936. exitPointerLock|expand|extractContents|fastSeek|firstChild|focus|forEach|get|
  1937. getAll|getAnimations|getAttribute|getAttributeNames|getAttributeNode|
  1938. getAttributeNodeNS|getAttributeNS|getBoundingClientRect|getBoxQuads|
  1939. getClientRects|getContext|getDestinationInsertionPoints|getElementById|
  1940. getElementsByClassName|getElementsByName|getElementsByTagName|
  1941. getElementsByTagNameNS|getItem|getNamedItem|getSelection|getStartDate|
  1942. getVideoPlaybackQuality|has|hasAttribute|hasAttributeNS|hasAttributes|
  1943. hasChildNodes|hasFeature|hasFocus|importNode|initEvent|insertAdjacentElement|
  1944. insertAdjacentHTML|insertAdjacentText|insertBefore|insertCell|insertData|
  1945. insertNode|insertRow|intersectsNode|isDefaultNamespace|isEqualNode|
  1946. isPointInRange|isSameNode|item|key|keys|lastChild|load|lookupNamespaceURI|
  1947. lookupPrefix|matches|move|moveAttribute|moveAttributeNode|moveChild|
  1948. moveNamedItem|namedItem|nextNode|nextSibling|normalize|observe|open|
  1949. parentNode|pause|play|postMessage|prepend|preventDefault|previousNode|
  1950. previousSibling|probablySupportsContext|queryCommandEnabled|
  1951. queryCommandIndeterm|queryCommandState|queryCommandSupported|queryCommandValue|
  1952. querySelector|querySelectorAll|registerContentHandler|registerElement|
  1953. registerProtocolHandler|releaseCapture|releaseEvents|remove|removeAttribute|
  1954. removeAttributeNode|removeAttributeNS|removeChild|removeEventListener|
  1955. removeItem|replace|replaceChild|replaceData|replaceWith|reportValidity|
  1956. requestFullscreen|requestPointerLock|reset|scroll|scrollBy|scrollIntoView|
  1957. scrollTo|seekToNextFrame|select|selectNode|selectNodeContents|set|setAttribute|
  1958. setAttributeNode|setAttributeNodeNS|setAttributeNS|setCapture|
  1959. setCustomValidity|setEnd|setEndAfter|setEndBefore|setItem|setNamedItem|
  1960. setRangeText|setSelectionRange|setSinkId|setStart|setStartAfter|setStartBefore|
  1961. slice|splitText|stepDown|stepUp|stopImmediatePropagation|stopPropagation|
  1962. submit|substringData|supports|surroundContents|takeRecords|terminate|toBlob|
  1963. toDataURL|toggle|toString|values|write|writeln
  1964. )
  1965. )(?=\s*\()
  1966. captures:
  1967. 1: punctuation.accessor.ts
  1968. 2: punctuation.accessor.optional.ts
  1969. 3: support.function.event-handler.ts
  1970. 4: support.function.ts
  1971. 5: support.function.dom.ts
  1972. switch-statement:
  1973. - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?=\bswitch\s*\()'
  1974. push:
  1975. - meta_scope: switch-statement.expr.ts
  1976. - match: '\}'
  1977. captures:
  1978. 0: punctuation.definition.block.ts
  1979. pop: true
  1980. - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(switch)\s*(\()'
  1981. captures:
  1982. 1: keyword.control.switch.ts
  1983. 2: meta.brace.round.ts
  1984. push:
  1985. - meta_scope: switch-expression.expr.ts
  1986. - match: \)
  1987. captures:
  1988. 0: meta.brace.round.ts
  1989. pop: true
  1990. - include: expression
  1991. - match: '\{'
  1992. captures:
  1993. 0: punctuation.definition.block.ts
  1994. push:
  1995. - meta_scope: switch-block.expr.ts
  1996. - match: '(?=\})'
  1997. pop: true
  1998. - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(case|default(?=:))(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))'
  1999. captures:
  2000. 1: keyword.control.switch.ts
  2001. push:
  2002. - meta_scope: case-clause.expr.ts
  2003. - match: ":"
  2004. captures:
  2005. 0: punctuation.definition.section.case-statement.ts
  2006. pop: true
  2007. - include: expression
  2008. - include: statements
  2009. template:
  2010. - match: "([_$[:alpha:]][_$[:alnum:]]*)?(`)"
  2011. captures:
  2012. 1: entity.name.function.tagged-template.ts
  2013. 2: punctuation.definition.string.template.begin.ts
  2014. push:
  2015. - meta_scope: string.template.ts
  2016. - match: "`"
  2017. captures:
  2018. 0: punctuation.definition.string.template.end.ts
  2019. pop: true
  2020. - include: template-substitution-element
  2021. - include: string-character-escape
  2022. template-substitution-element:
  2023. - match: '\$\{'
  2024. captures:
  2025. 0: punctuation.definition.template-expression.begin.ts
  2026. push:
  2027. - meta_scope: meta.template.expression.ts
  2028. - meta_content_scope: meta.embedded.line.ts
  2029. - match: '\}'
  2030. captures:
  2031. 0: punctuation.definition.template-expression.end.ts
  2032. pop: true
  2033. - include: expression
  2034. ternary-expression:
  2035. - match: '(?!\?\.\s*[^[:digit:]])(\?)'
  2036. captures:
  2037. 1: keyword.operator.ternary.ts
  2038. push:
  2039. - match: (:)
  2040. captures:
  2041. 0: keyword.operator.ternary.ts
  2042. pop: true
  2043. - include: expression
  2044. this-literal:
  2045. - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))this\b(?!\$)'
  2046. scope: variable.language.this.ts
  2047. type:
  2048. - include: comment
  2049. - include: string
  2050. - include: numeric-literal
  2051. - include: type-primitive
  2052. - include: type-builtin-literals
  2053. - include: type-parameters
  2054. - include: type-tuple
  2055. - include: type-object
  2056. - include: type-operators
  2057. - include: type-fn-type-parameters
  2058. - include: type-paren-or-function-parameters
  2059. - include: type-function-return-type
  2060. - include: type-name
  2061. type-alias-declaration:
  2062. - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(\bexport)\s+)?\b(type)\b\s+([_$[:alpha:]][_$[:alnum:]]*)\s*'
  2063. captures:
  2064. 1: keyword.control.export.ts
  2065. 2: storage.type.type.ts
  2066. 3: entity.name.type.alias.ts
  2067. push:
  2068. - meta_scope: meta.type.declaration.ts
  2069. - match: '(?=[};]|\babstract\b|\basync\b|\bclass\b|\bconst\b|\bdeclare\b|\benum\b|\bexport\b|\bfunction\b|\bimport\b|\binterface\b|\blet\b|\bmodule\b|\bnamespace\b|\btype\b|\bvar\b)'
  2070. pop: true
  2071. - include: comment
  2072. - include: type-parameters
  2073. - include: type
  2074. - match: (=)\s*
  2075. captures:
  2076. 1: keyword.operator.assignment.ts
  2077. type-annotation:
  2078. - match: (:)(?=\s*\S)
  2079. captures:
  2080. 1: keyword.operator.type.annotation.ts
  2081. push:
  2082. - meta_scope: meta.type.annotation.ts
  2083. - match: '(?<![:|&])((?=$|^|[,);\}\]]|//)|(?==[^>])|((?<=[\}>\]\)]|[_$[:alpha:]])\s*(?=\{)))'
  2084. pop: true
  2085. - include: type
  2086. - match: (:)
  2087. captures:
  2088. 1: keyword.operator.type.annotation.ts
  2089. push:
  2090. - meta_scope: meta.type.annotation.ts
  2091. - match: '(?<![:|&])((?=[,);\}\]]|//)|(?==[^>])|(?=^\s*$)|((?<=\S)(?=\s*$))|((?<=[\}>\]\)]|[_$[:alpha:]])\s*(?=\{)))'
  2092. pop: true
  2093. - include: type
  2094. type-builtin-literals:
  2095. - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(this|true|false|undefined|null|object)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))'
  2096. scope: support.type.builtin.ts
  2097. type-fn-type-parameters:
  2098. - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(new)\b(?=\s*\<)'
  2099. scope: meta.type.constructor.ts
  2100. captures:
  2101. 1: keyword.control.new.ts
  2102. - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(new)\b\s*(?=\()'
  2103. captures:
  2104. 1: keyword.control.new.ts
  2105. push:
  2106. - meta_scope: meta.type.constructor.ts
  2107. - match: (?<=\))
  2108. pop: true
  2109. - include: function-parameters
  2110. - match: |-
  2111. (?x)(
  2112. (?=
  2113. [(]\s*(
  2114. ([)]) |
  2115. (\.\.\.) |
  2116. ([_$[:alnum:]]+\s*(
  2117. ([:,?=])|
  2118. ([)]\s*=>)
  2119. ))
  2120. )
  2121. )
  2122. )
  2123. push:
  2124. - meta_scope: meta.type.function.ts
  2125. - match: (?<=\))
  2126. pop: true
  2127. - include: function-parameters
  2128. type-function-return-type:
  2129. - match: (=>)(?=\s*\S)
  2130. captures:
  2131. 1: storage.type.function.arrow.ts
  2132. push:
  2133. - meta_scope: meta.type.function.return.ts
  2134. - match: '(?<!=>)(?<![|&])(?=[,\]\)\{\}=;>]|//|$)'
  2135. pop: true
  2136. - include: type-function-return-type-core
  2137. - match: "=>"
  2138. captures:
  2139. 0: storage.type.function.arrow.ts
  2140. push:
  2141. - meta_scope: meta.type.function.return.ts
  2142. - match: '(?<!=>)(?<![|&])((?=[,\]\)\{\}=;>]|//|^\s*$)|((?<=\S)(?=\s*$)))'
  2143. pop: true
  2144. - include: type-function-return-type-core
  2145. type-function-return-type-core:
  2146. - include: comment
  2147. - match: '(?<==>)(?=\s*\{)'
  2148. push:
  2149. - match: '(?<=\})'
  2150. pop: true
  2151. - include: type-object
  2152. - include: type-predicate-operator
  2153. - include: type
  2154. type-name:
  2155. - match: '([_$[:alpha:]][_$[:alnum:]]*)\s*(?:(\.)|(\?\.(?!\s*[[:digit:]])))'
  2156. captures:
  2157. 1: entity.name.type.module.ts
  2158. 2: punctuation.accessor.ts
  2159. 3: punctuation.accessor.optional.ts
  2160. - match: "[_$[:alpha:]][_$[:alnum:]]*"
  2161. scope: entity.name.type.ts
  2162. type-object:
  2163. - match: '\{'
  2164. captures:
  2165. 0: punctuation.definition.block.ts
  2166. push:
  2167. - meta_scope: meta.object.type.ts
  2168. - match: '\}'
  2169. captures:
  2170. 0: punctuation.definition.block.ts
  2171. pop: true
  2172. - include: comment
  2173. - include: method-declaration
  2174. - include: indexer-declaration
  2175. - include: indexer-mapped-type-declaration
  2176. - include: field-declaration
  2177. - include: type-annotation
  2178. - match: \.\.\.
  2179. captures:
  2180. 0: keyword.operator.spread.ts
  2181. push:
  2182. - match: '(?=\}|;|,|$)|(?<=\})'
  2183. pop: true
  2184. - include: type
  2185. - include: punctuation-comma
  2186. - include: punctuation-semicolon
  2187. - include: type
  2188. type-operators:
  2189. - include: typeof-operator
  2190. - match: '([&|])(?=\s*\{)'
  2191. captures:
  2192. 0: keyword.operator.type.ts
  2193. push:
  2194. - match: '(?<=\})'
  2195. pop: true
  2196. - include: type-object
  2197. - match: "[&|]"
  2198. captures:
  2199. 0: keyword.operator.type.ts
  2200. push:
  2201. - match: (?=\S)
  2202. pop: true
  2203. - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))keyof(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))'
  2204. scope: keyword.operator.expression.keyof.ts
  2205. type-parameters:
  2206. - match: (<)
  2207. captures:
  2208. 1: punctuation.definition.typeparameters.begin.ts
  2209. push:
  2210. - meta_scope: meta.type.parameters.ts
  2211. - match: (>)
  2212. captures:
  2213. 1: punctuation.definition.typeparameters.end.ts
  2214. pop: true
  2215. - include: comment
  2216. - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(extends)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))'
  2217. scope: storage.modifier.ts
  2218. - match: \=(?!>)
  2219. scope: keyword.operator.assignment.ts
  2220. - include: type
  2221. - include: punctuation-comma
  2222. type-paren-or-function-parameters:
  2223. - match: \(
  2224. captures:
  2225. 0: meta.brace.round.ts
  2226. push:
  2227. - meta_scope: meta.type.paren.cover.ts
  2228. - match: \)
  2229. captures:
  2230. 0: meta.brace.round.ts
  2231. pop: true
  2232. - include: type
  2233. - include: function-parameters
  2234. type-predicate-operator:
  2235. - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))is(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))'
  2236. scope: keyword.operator.expression.is.ts
  2237. type-primitive:
  2238. - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(string|number|boolean|symbol|any|void|never)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))'
  2239. scope: support.type.primitive.ts
  2240. type-tuple:
  2241. - match: '\['
  2242. captures:
  2243. 0: meta.brace.square.ts
  2244. push:
  2245. - meta_scope: meta.type.tuple.ts
  2246. - match: '\]'
  2247. captures:
  2248. 0: meta.brace.square.ts
  2249. pop: true
  2250. - include: type
  2251. - include: punctuation-comma
  2252. typeof-operator:
  2253. - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))typeof(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))'
  2254. scope: keyword.operator.expression.typeof.ts
  2255. undefined-literal:
  2256. - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))undefined(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))'
  2257. scope: constant.language.undefined.ts
  2258. var-expr:
  2259. - match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(\bexport)\s+)?\b(var|let|const(?!\s+enum\b))(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))'
  2260. captures:
  2261. 1: keyword.control.export.ts
  2262. 2: storage.type.ts
  2263. push:
  2264. - meta_scope: meta.var.expr.ts
  2265. - match: '(?=$|^|;|}|(\s+(of|in)\s+))'
  2266. pop: true
  2267. - include: destructuring-variable
  2268. - include: var-single-variable
  2269. - include: variable-initializer
  2270. - include: comment
  2271. - match: (,)\s*(?!\S)
  2272. captures:
  2273. 1: punctuation.separator.comma.ts
  2274. push:
  2275. - match: '(?<!,)((?==|;|}|(\s+(of|in)\s+)|^\s*$))|((?<=\S)(?=\s*$))'
  2276. pop: true
  2277. - include: comment
  2278. - include: destructuring-variable
  2279. - include: var-single-variable
  2280. - include: punctuation-comma
  2281. - include: punctuation-comma
  2282. var-single-variable:
  2283. - match: |-
  2284. (?x)([_$[:alpha:]][_$[:alnum:]]*)(?=\s*
  2285. # function assignment |
  2286. (=\s*(
  2287. ((async\s+)?(
  2288. (function\s*[(<*]) |
  2289. (function\s+) |
  2290. ([_$[:alpha:]][_$[:alnum:]]*\s*=>)
  2291. )) |
  2292. ((async\s*)?(
  2293. # sure shot arrow functions even if => is on new line
  2294. (
  2295. [(]\s*
  2296. (
  2297. ([)]\s*:) | # ():
  2298. ((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param:
  2299. )
  2300. ) |
  2301. (
  2302. [<]\s*[_$[:alpha:]][_$[:alnum:]]*\s+extends\s*[^=>] # < typeparam extends
  2303. ) |
  2304. # arrow function possible to detect only with => on same line
  2305. (
  2306. (<\s*([_$[:alpha:]]|(\{[^\{\}]*\})|(\([^\(\)]*\))|(\[[^\[\]]*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{[^\{\}]*\})|(\([^\(\)]*\))|(\[[^\[\]]*\]))([^=<>]|=[^<])*\>)*>\s*)? # typeparameters
  2307. \(\s*([_$[:alpha:]\{\[]([^()]|\((\s*[^()]*)?\))*)?\) # parameteres
  2308. (\s*:\s*([^<>\(\)]|\<[^<>]+\>|\([^\(\)]+\))+)? # return type
  2309. \s*=> # arrow operator
  2310. )
  2311. ))
  2312. )) |
  2313. # typeannotation is fn type: < | () | (... | (param: | (param, | (param? | (param= | (param) =>
  2314. (:\s*(
  2315. (<) |
  2316. ([(]\s*(
  2317. ([)]) |
  2318. (\.\.\.) |
  2319. ([_$[:alnum:]]+\s*(
  2320. ([:,?=])|
  2321. ([)]\s*=>)
  2322. ))
  2323. ))
  2324. )))
  2325. captures:
  2326. 1: meta.definition.variable.ts entity.name.function.ts
  2327. push:
  2328. - meta_scope: meta.var-single-variable.expr.ts
  2329. - match: '(?=$|^|[;,=}]|(\s+(of|in)\s+))'
  2330. pop: true
  2331. - include: var-single-variable-type-annotation
  2332. - match: "([[:upper:]][_$[:digit:][:upper:]]*)(?![_$[:alnum:]])"
  2333. captures:
  2334. 1: meta.definition.variable.ts variable.other.constant.ts
  2335. push:
  2336. - meta_scope: meta.var-single-variable.expr.ts
  2337. - match: '(?=$|^|[;,=}]|(\s+(of|in)\s+))'
  2338. pop: true
  2339. - include: var-single-variable-type-annotation
  2340. - match: "([_$[:alpha:]][_$[:alnum:]]*)"
  2341. captures:
  2342. 1: meta.definition.variable.ts variable.other.readwrite.ts
  2343. push:
  2344. - meta_scope: meta.var-single-variable.expr.ts
  2345. - match: '(?=$|^|[;,=}]|(\s+(of|in)\s+))'
  2346. pop: true
  2347. - include: var-single-variable-type-annotation
  2348. var-single-variable-type-annotation:
  2349. - include: type-annotation
  2350. - include: string
  2351. - include: comment
  2352. variable-initializer:
  2353. - match: (?<!=|!)(=)(?!=)(?=\s*\S)
  2354. captures:
  2355. 1: keyword.operator.assignment.ts
  2356. push:
  2357. - match: '(?=$|^|[,);}\]])'
  2358. pop: true
  2359. - include: expression
  2360. - match: (?<!=|!)(=)(?!=)
  2361. captures:
  2362. 1: keyword.operator.assignment.ts
  2363. push:
  2364. - match: '(?=[,);}\]])|(?=^\s*$)|(?<=\S)(?<!=)(?=\s*$)'
  2365. pop: true
  2366. - include: expression