Lukass
October 16, 2021, 3:46am
1
Hi. I’m trying to find the reason why Generics are highlighted with an error for the TypeScript. I saw that Hugo uses Chroma to render the backlight and there really was a problem with the TypeScript, but Issue was closed. What could be the problem? Hugo version 0.88.1
Issue on git:
opened 06:34PM - 21 Nov 20 UTC
help wanted
lexer bug
**Describe the bug**
Chroma seems to not understand TypeScript generics with … multiple template arguments and/or template arguments using a generic type too.
Consider the following TypeScript code:
```ts
export class AuditingRepository<
T extends Entity,
ID,
Relations extends object = {}
> extends DefaultCrudRepository<T, ID, Relations> {
}
```
Chroma v0.8.2 and Hugo v0.78.2 render the code with a comma (`,`) characters highlighted in red - perhaps suggesting an error?

**To Reproduce**
Save the following text to `bug.ts`.
```ts
export class AuditingRepository<
T extends Entity,
ID,
Relations extends object = {}
> extends DefaultCrudRepository<T, ID, Relations> {
}
```
Run chroma as follows:
```
chroma -s autumn --html --html-lines --html-lines-table --html-inline-styles bug.ts > bug.html
```
Open the produced HTML file in a Chromium-based browers. You should see the same output as on my screenshot posted above.
Problem screen:
1 Like
The issue you referenced is still open.
1 Like