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 #26496

Closed
axefrog opened this issue May 11, 2017 · 3 comments
Closed
Assignees
Labels
javascript JavaScript support issues languages-basic Basic language support issues typescript Typescript support issues upstream Issue identified as 'upstream' component related (exists outside of VS Code)

Comments

@axefrog
Copy link

axefrog commented May 11, 2017

  • 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.

@mjbvz mjbvz self-assigned this May 12, 2017
@mjbvz mjbvz added the info-needed Issue requires more information from poster label May 12, 2017
@mjbvz
Copy link
Collaborator

mjbvz commented May 12, 2017

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

@mjbvz mjbvz closed this as completed May 12, 2017
@mjbvz mjbvz reopened this May 12, 2017
@axefrog
Copy link
Author

axefrog commented May 12, 2017

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';
  }
}

@mjbvz
Copy link
Collaborator

mjbvz commented May 12, 2017

This issue was moved to microsoft/TypeScript-TmLanguage#453

@mjbvz mjbvz closed this as completed May 12, 2017
@mjbvz mjbvz added javascript JavaScript support issues typescript Typescript support issues upstream Issue identified as 'upstream' component related (exists outside of VS Code) languages-basic Basic language support issues labels May 12, 2017
@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
javascript JavaScript support issues languages-basic Basic language support issues typescript Typescript support issues upstream Issue identified as 'upstream' component related (exists outside of VS Code)
Projects
None yet
Development

No branches or pull requests

2 participants