Skip to content
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

Code not properly colorized in Typescript with conditional return types #748

Closed
h-Reser opened this issue May 5, 2019 · 1 comment
Closed

Comments

@h-Reser
Copy link

h-Reser commented May 5, 2019

  • VSCode Version: 1.33.1 & 1.34.0 (Insiders)
  • OS Version: Windows 10 x64

Steps to Reproduce:
Write the following code in a new Typescript file:

type X = A | B;
type A = string;
type B = number;
function foo<T extends X>(arg: T): T extends B ? number : string {
  if (arg === "A") return <T extends B ? number : never>111;
  return <T extends B ? never : string>"returning a string";
}
foo("A");
foo(1);

In my project, I need to use a function with the typing described in the code above. This is of course a simplified version of my code. The code passes the Typescript 3.4.3 without errors, and also works at run time.
However, the colorization of the code bugs after the if statement.
bad colorization

If I remove the parameters from the return statements, then the colorization works. But the code doesn't pass the type-check anymore.
normal colorization

I get the same result with and without extensions. Also with the latest insiders build of VS Code.

@vscodebot vscodebot bot assigned mjbvz May 5, 2019
@mjbvz mjbvz transferred this issue from microsoft/vscode May 6, 2019
@mjbvz
Copy link
Contributor

mjbvz commented May 6, 2019

I confirmed this using the latest grammar version

@mjbvz mjbvz removed their assignment May 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants