codemirror / dev

Development repository for the CodeMirror editor project
https://codemirror.net/
Other
5.44k stars 343 forks source link

Typescript generic breaks highlighting #1377

Closed masad-frost closed 2 months ago

masad-frost commented 2 months ago

Describe the issue

I don't know what the root cause is but here's the most minimal example I could come up with.

type Foo = Bar<typeof baz<Corge<Quux>>>;

// Things get messed up here
export type Wow = number;

in CodeMirror: image

I think the typeof baz< is the problematic bit, if I change that to Baz< the syntax works.

Browser and platform

any

Reproduction link

https://codemirror.net/try/?c=aW1wb3J0IHtiYXNpY1NldHVwLCBFZGl0b3JWaWV3fSBmcm9tICJjb2RlbWlycm9yIgppbXBvcnQge2phdmFzY3JpcHR9IGZyb20gIkBjb2RlbWlycm9yL2xhbmctamF2YXNjcmlwdCIKCm5ldyBFZGl0b3JWaWV3KHsKICBkb2M6IGB0eXBlIEZvbyA9IEJhcjx0eXBlb2YgYmF6PENvcmdlPFF1dXg+Pj47CgovLyBUaGluZ3MgZ2V0IG1lc3NlZCB1cCBoZXJlCmV4cG9ydCB0eXBlIFdvdyA9IG51bWJlcjsKYCwKICBleHRlbnNpb25zOiBbYmFzaWNTZXR1cCwgamF2YXNjcmlwdCh7IHR5cGVzY3JpcHQ6IHRydWUgfSldLAogIHBhcmVudDogZG9jdW1lbnQuYm9keQp9KQo=

marijnh commented 2 months ago

It wasn't accepting type arguments on the (non-call) baz expression. But it seems TypeScript supports this now. Added in attached patch.