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

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

Open
OzelotVanilla opened this issue Oct 16, 2023 · 0 comments

Comments

@OzelotVanilla
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant