1 - https://github.com/antlr/grammars-v4/blob/master/javascript/...
Why Antlr is not the one? Hope the following blog I wrote may explain.
https://blog.caoccao.com/hello-swc4j-goodbye-antlr-f9a63e45a...
Admittedly I haven't tested the TypeScript treesitter grammar, but I'd be surprised if the issue is fixed there. I've put together a sample file[1] that demonstrates various cases of these context dependencies. If I remember correctly, Sublime's highlighter was the best at handling these cases out of various editors I tried, though it still failed at some of the ones at the bottom involving multi-line function expressions within object literal keys. GitHub/gist uses treesitter, so you'll notice that sometimes the "REGEX" and "DIVISION" blocks are inconsistently coloured, but a correct parser should associate a colour consistently to them. Not demonstrated here, but inserting a multi-line comment in a file that is parsed incorrectly will throw the entire thing off.
[0] https://github.com/tree-sitter/tree-sitter-javascript/issues...
[1] https://gist.github.com/Maxdamantus/a11b41675fcde25ffc9b7ef0...
> Edit: unfortunately, this seems to be a JNI bridge to the Rust code in SWC, I was hoping for a JVM-native solution.
Maybe tree-sitter[0] TypeScript support[1] could do the trick?
HTH0 - https://tree-sitter.github.io/tree-sitter/
1 - https://github.com/tree-sitter/tree-sitter-typescript