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.

TypeScriptReact.sublime-syntax 91KB

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