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

TypeScript non-null assertion operator breaks subsequent syntax highlighting #453

Closed
mjbvz opened this issue May 12, 2017 · 2 comments
Closed

Comments

@mjbvz
Copy link
Contributor

mjbvz commented May 12, 2017

From @axefrog on May 11, 2017 23:38

  • VSCode Version: 1.12.1
  • OS Version: Windows 10

Without non-null assertion operator:

image

With non-null assertion operator:

image

The only difference between the above two examples is the presence of a non-null assertion postfix operator after the expression vars.get(name).

I've tried switching through all my color themes, and they all have the same issue, suggesting this is an issue with the way TypeScript is being tokenized, rather than with any particular theme itself.

Copied from original issue: microsoft/vscode#26496

@mjbvz
Copy link
Contributor Author

mjbvz commented May 12, 2017

Please post up the source of the examples along with the screenshots

@mjbvz
Copy link
Contributor Author

mjbvz commented May 12, 2017

From @axefrog on May 12, 2017 1:45

type Resolve = () => number;

class Test {
  first(values: Map<string, Resolve>): number {
    return values.has('a') ? values.get('a')!() : 0;
  }

  second(): string {
    return 'foo';
  }
}

Seems to be an interplay between the ternary operator, the not-null assertion operator and function call parentheses. Even the syntax highlighting for the above code sample here on Github seems to show a similar issue.

Workaround is to put parentheses around the asserted expression:

type Resolve = () => number;

class Test {
  first(values: Map<string, Resolve>): number {
    return values.has('a') ? (values.get('a')!)() : 0;
  }

  second(): string {
    return 'foo';
  }
}

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

1 participant