Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Syntax fails when function declaration return type is on a separate line #677

Closed
mgthomas99 opened this issue Oct 31, 2018 · 0 comments
Closed

Comments

@mgthomas99
Copy link

mgthomas99 commented Oct 31, 2018

TS and JS Grammar Extension version: 0.0.46 / latest

Code

function main(url: string)
: Promise<any> {
    return new Promise((accept, reject) => {
        const text = window.prompt();
        accept(text);
    });
}

In the code snippet above, notice the incorrect syntax highlighting of the function body's first expression (return new Promise(...)). The effect of the incorrect syntax is most visible in Visual Studio Code (notice lines 4 and 11):

vscode
lambda

Here is the expected syntax highlighting:

expected

Interestingly, the issue on line 4 can be fixed by wrapping the return type in parentheses, but this does not fix the issue on line 11:

tempfix

Furthermore, it appears as though the syntax highlighting of an arrow function's name and return type is dependent on the arrangement of its parameters:

lambdas2

This bug cannot be attributed to VS Code as it also appears in VS Code Insiders, and continues to appear even after I have disabled all extensions.

@mgthomas99 mgthomas99 changed the title Syntax fails when : <type> is on a new line Syntax fails when : <type> is on a separate line to function declaration Oct 31, 2018
@mgthomas99 mgthomas99 changed the title Syntax fails when : <type> is on a separate line to function declaration Syntax fails when function declaration return type is on a separate line Oct 31, 2018
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant