title: How to highlight all TypeScript annotations (tokens) in VSCode?
body: <p>I was onboarding an experienced developer to TSX and faced a problem that I did not expect. When modern JavaScript is combined with JSX and TypeScript annotations, symbols like <code>(</code> <code>)</code> <code>[</code> <code>]</code> <code>{</code> <code>}</code> <code>&lt;</code> <code>&gt;</code> <code>:</code> end up playing too many roles and this becomes a significant learning barrier. Even a slightest change in a file can completely flip the meaning of the syntax used.</p>
  <p>Our brain is adaptive, so folks who code modern web apps full time can easily read TSX and appreciate how expressive it is. But imagine it is your first project and you’ve only worked with ES5 before. Why is <code>&lt;Foo&gt;{x}...</code> a React node but <code>&lt;Foo&gt;(x: Foo) =&gt; void</code> is a generic function type? What is going on in<code>({ param: myParam = 42 }: { param: number })</code>?</p>
  <p>Learning JSX and TypeScript step-by-step is the best approach, but it is not really necessary for experienced engineers who just need to pick a yet another dialect of a yet another language. The idea of code transpiling is simple, but the syntax is initially hard. What would help is some keyboard shortcut that would highlight TS-only stuff:</p>
  <p><a href="https://i.stack.imgur.com/8AXTQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8AXTQ.png" alt="tsx file with manually highlighted typescript annotations" /></a></p>
  <p>In practice, it’d be cool to have one command that temporarily dims all TS annotations and another command that dims everything but TS.</p>
  <p><a href="https://i.stack.imgur.com/CdJaa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CdJaa.png" alt="left: TS tokens dimmed, right: JS tokens dimmed" /></a></p>
  <p>Of course, <a href="https://www.typescriptlang.org/docs/handbook/enums.html" rel="nofollow noreferrer">enums</a> would need to have some special treatment because they impact both typings and JS runtime. However, this is a rare exception in the language so I would not worry about it too much.</p>
  <p>I know that there exist online AST parsers, but they are too scary and can potentially make the onboarding worse. VS Code has a lot of flexibility, so how can we leverage it in some affordable way? What theme or extension to use?</p>