typescript conditional types
nicolasgargano opened this issue · comments
Hi, I ran into some issues while trying out CodeMirror 6 for typescript and I think it's due to this package.
In CodeMirror (live, source). Also notice that with jsx enabled it gets confused.
In VSCode/Monaco with a similar theme (TS Playground). The pic is from a .tsx file.
I thought it could be the theme but the html also turns out different. For the first example notice that the Y is missing the <span>.
(() => T extends X ? 1 : 2) extends | (() => T extends Y ? 1 : 2) ? true : false |
---|---|
![]() |
![]() |
I tried adding a simple test case to this parser and it throws SyntaxError: No parse at 23
. (TS Playground)
(ignore the expected value, it's from another existing test)
# SimpleConditionalType {"dialect": "ts"}
type IsLiteralA<T> = T extends "A" ? true : false
==>
Script(EnumDeclaration(const, enum, TypeDefinition, EnumBody(PropertyName, Equals, Number, PropertyName, PropertyName)))
If you agree these are worth fixing, let me know what's the best format to report any other error like this. I'm trying to load stuff from https://github.com/type-challenges/type-challenges into CodeMirror, so I can take notes if I run into issues with some more complicated types.
Attached patches (released in @lezer/javascript 1.0.1) seem to make that snippet parse properly.