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

Null Coalesce Operator Breaks Syntax Highlight in Visual Studio 2017 #35725

Closed
busyscout opened this issue Dec 17, 2019 · 2 comments
Closed

Null Coalesce Operator Breaks Syntax Highlight in Visual Studio 2017 #35725

busyscout opened this issue Dec 17, 2019 · 2 comments
Assignees
Labels
Bug A bug in TypeScript Visual Studio Integration with Visual Studio

Comments

@busyscout
Copy link

Null coalesce operator breaks syntax highlighting in VS2017.
Example:

class NullCoalesceTest {
    private test() {
        const x = this.getNumber();
        const y = this.getNumber();
        //this.add(x, y); //error
        this.add(x || 0, y || 0); //OK
        this.add(x ?? 0, y ?? 0); //Breaks syntax highlighting in VS2017
    }

    private getNumber() {
        if (new Date().getMilliseconds() % 2 === 0)
            return 1;
        return null;
    }

    private add(x: number, y: number) {
        return x + y;
    }
}

VS 2017
VS2017 Null Coalesce

VS 2019
VS2019 Null Coalesce

Typescript 3.7.3.

@DanielRosenwasser DanielRosenwasser added Visual Studio Integration with Visual Studio Bug A bug in TypeScript labels Jan 15, 2020
@busyscout
Copy link
Author

busyscout commented Jan 15, 2020 via email

@minestarks
Copy link
Member

minestarks commented Jan 18, 2020

Unfortunately this isn't something we'll be able to fix for VS 2017 since syntax highlighting in VS uses the TextMate grammar files, which can't be updated out of band. The new syntax is supported in VS 2019 16.4 onwards.

Here's a (admittedly slightly hacky) workaround you can use: Copy the contents of Common7\IDE\CommonExtensions\Microsoft\TypeScript\tmLanguage from a VS 2019 16.4 (or higher) installation over to your VS 2017 installation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Visual Studio Integration with Visual Studio
Projects
None yet
Development

No branches or pull requests

3 participants