Skip to content

JavaScript reports errors on on async shorthand with for-of loop in lambda object #19134

@mjbvz

Description

@mjbvz

From microsoft/vscode#36153

TypeScript Version: 2.6.0

Code
For the JS

let validLambda = () => ({
    async bla() {
        for ( let i of [] ) {
            console.log(i)
        }
    }
})

Expected behavior:
No errors

Actual behavior:

The following errors are reported:

[Trace  - 10:41:27] Event received: syntaxDiag (0).
Data: {
    "file": "/Users/matb/projects/san/test.js",
    "diagnostics": [
        {
            "start": {
                "line": 2,
                "offset": 11
            },
            "end": {
                "line": 2,
                "offset": 14
            },
            "text": "'=' expected.",
            "code": 1005,
            "category": "error"
        },
        {
            "start": {
                "line": 2,
                "offset": 17
            },
            "end": {
                "line": 2,
                "offset": 18
            },
            "text": "',' expected.",
            "code": 1005,
            "category": "error"
        },
        {
            "start": {
                "line": 3,
                "offset": 13
            },
            "end": {
                "line": 3,
                "offset": 14
            },
            "text": "':' expected.",
            "code": 1005,
            "category": "error"
        },
        {
            "start": {
                "line": 3,
                "offset": 19
            },
            "end": {
                "line": 3,
                "offset": 20
            },
            "text": "')' expected.",
            "code": 1005,
            "category": "error"
        },
        {
            "start": {
                "line": 3,
                "offset": 21
            },
            "end": {
                "line": 3,
                "offset": 23
            },
            "text": "'=' expected.",
            "code": 1005,
            "category": "error"
        },
        {
            "start": {
                "line": 3,
                "offset": 27
            },
            "end": {
                "line": 3,
                "offset": 28
            },
            "text": "',' expected.",
            "code": 1005,
            "category": "error"
        },
        {
            "start": {
                "line": 3,
                "offset": 29
            },
            "end": {
                "line": 3,
                "offset": 30
            },
            "text": "'=>' expected.",
            "code": 1005,
            "category": "error"
        },
        {
            "start": {
                "line": 6,
                "offset": 5
            },
            "end": {
                "line": 6,
                "offset": 6
            },
            "text": "Declaration or statement expected.",
            "code": 1128,
            "category": "error"
        },
        {
            "start": {
                "line": 7,
                "offset": 1
            },
            "end": {
                "line": 7,
                "offset": 2
            },
            "text": "Declaration or statement expected.",
            "code": 1128,
            "category": "error"
        },
        {
            "start": {
                "line": 7,
                "offset": 2
            },
            "end": {
                "line": 7,
                "offset": 3
            },
            "text": "Declaration or statement expected.",
            "code": 1128,
            "category": "error"
        }
    ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptFixedA PR has been merged for this issueVS Code TrackedThere is a VS Code equivalent to this issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions