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.

TypeScript.sublime-syntax 85KB

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