Skip to content

Tokenising failure on parenthesis-wrapped object literal's type assertion operators as keyof typeof #995

@OzelotVanilla

Description

@OzelotVanilla

JavaScript and TypeScript Nightly version: 5.3.0-dev.20231015

Code

This is the minimal and possible code for compare and constrast.
The example might not cover all posibilities that leads to this issue.

type A = { a: "", b: "" }
const a = { a: "", b: "" }

const c = ({
    key: a.a, label: a.b[a.a as keyof typeof a.b]
})

const d = (
    {
        key: a.a, label: a.b[a.a as keyof typeof a.b]
    })

const e =
    { key: a.a, label: a.b[a.a as keyof typeof a.b] }

const f =
{
    key: a.a, label: a.b[a.a as keyof typeof a.b]
}

When the object literal is going to be written like d, the inner operator as keyof typeof is tokenised as variable.parameter.ts or (tsx), but not keyword.*.

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions