-
Notifications
You must be signed in to change notification settings - Fork 588
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[JavaScript] TypeScript cast throws off further highlighting #3862
Comments
Ugh. It's surely parsing this as |
Not sure if I understand how you intend to fix it but note that instead of |
I don't think The solution I'm trying is removing the type argument handling from |
N.B. While I think that |
you're right |
Should be fixed in the linked PR. |
Note that the community likes to omit semicolons for the sake of cleaner code. So that... :) |
Eh, only so much we can do in such cases. For one thing, there's no way to detect EOF, so it's almost impossible to handle some otherwise-ambiguous constructs right before EOF. Here, it's invalid syntax either way, so highlighting is on a best-effort basis. I didn't bother addressing that case in the linked PR because the solution for the valid case turned out to be simple. I did note that VSCode's fails in the same way in the invalid case, for what that's worth. |
Fix #3862. Originally, type arguments were part of the regular type expression structure, so the syntax would try to highlight type arguments after any type. But actually, only ordinary named types can get them. In the linked issue, this was causing problems with `as`-style type assertions — when followed by a `<`, the type expression was eating it and trying to parse type arguments, even when the preceding type does not accept them. According to the spec — I'm kidding, we all know the drill by now, actually after a bunch of futzing around in AST Explorer — this should work correctly in all cases I can think of. In order for this to work in all cases, it's necessary to ensure that all specially keyworded types are accounted for, so this PR also adds the `true` and `false` singleton types.
What happened?
This probably can be simplified quite a bit.
Things already seem wrongly colored on the
two
method, after the cast.The text was updated successfully, but these errors were encountered: