1

Lately I've noticed the syntax highlighting for questions is not applying when the code fence hint

```ts

or

```lang-ts

is used.

Example question - How to have TypeScript show computed/simplified type

Dark Mode Light Mode
dark mode screenshot light mode screenshot

The question (at the time of posting) is tagged correctly and also uses code fences

```ts
export type UnionExpanded<$Union> = $Union

export type HandleReturn2<$Data> = UnionExpanded<$Data | 2>
```

Using lang-ts also fails but updating even one code fence to use lang-typescript seems to fix all code blocks.

Removing the hint and letting the tag take priority also works.


This always used to work and is also listed in What is syntax highlighting and how does it work?

  • TypeScript: lang-typescript, (lang-ts, lang-tsx, lang-mts, lang-cts)
7
  • 3
  • Are ts and lang-ts even recognized? The name of the tag is typescript, and the tag wiki indicates that the syntax highlighting language is lang-js, not lang-ts.
    – Anerdw
    Commented Oct 14 at 1:55
  • @Anerdw they always used to work
    – Phil
    Commented Oct 14 at 2:20
  • Upon further inspection, it does look like lang-ts is officially supported. ts isn't a synonym for typescript, though - why did that one used to work?
    – Anerdw
    Commented Oct 14 at 2:23
  • I'm not going to mark this [status-review] since the post on MSE that Kevin B linked is already in that state. As outlined in that post there are two issues, (1) it appears the staff changes to highlighting logic did not update the front-end preview window at all to use the new logic and (2) that the backend logic doesn't account for any of the supported HLJS aliases.
    – Henry Ecker Mod
    Commented Oct 14 at 2:56
  • 3
    For the moment either typescript to pull in the JavaScript highlighting or lang-typescript will (should) function as expected. Somewhat relatedly, with the new behaviour, it might also be time to take a second look at Change Default Syntax Highlighting for [typescript] from lang-js to lang-typescript
    – Henry Ecker Mod
    Commented Oct 14 at 3:00
  • 1
    @Anerdw "why did that one used to work?" - well I presume because "ts" is a known alias that highlight.js supports - highlightjs.readthedocs.io/en/latest/supported-languages.html.
    – Gimby
    Commented Oct 15 at 12:27

0

You must log in to answer this question.

Browse other questions tagged .