riptano / docs-ui

The UI and theme for DataStax Docs.
https://riptano.github.io/docs-ui/
Mozilla Public License 2.0
2 stars 0 forks source link

TypeScript syntax highlighting issue #119

Open eric-schneider opened 3 months ago

eric-schneider commented 3 months ago

Reported by @toptobes:

Syntax highlighting breaks when you have an immediately-invoked function expression (IIFE) that's an arrow function:

image (9)

Works fine with old-school function expressions:

image (10)

All I can say is that when making an IIFE using an arrow function, it renders the body of it improperly (as shown in the first image), But for some reason, renders properly when you declare an interface before it (so I'd imagine it might work if you declare a class or type before it? Haven't tested it yet though.)

image (8)

eric-schneider commented 3 months ago

We use highlight.js for syntax highlighting. My guess is that this is an issue with the language definition itself (included in the core library): https://github.com/highlightjs/highlight.js/blob/main/src/languages/typescript.js

The highlight.js project maintains the core language definitions, so we should probably follow up by filing an issue. Alternatively, we can try and find a 3rd party TS definition and test whether it has the same highlighting issue.