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 107KB

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