Skip to content

TypeError: Cannot read properties of undefined (reading 'type') #15912

@epmatsw

Description

@epmatsw

Prettier 3.2.0
Playground link

--parser typescript

Input:

test()
	.test2()
	.test2(thing?.something);

Output:

TypeError: Cannot read properties of undefined (reading 'type')
    at Jn (https://prettier.io/lib/plugins/estree.js:7:16595)
    at be (https://prettier.io/lib/plugins/estree.js:9:605)
    at be (https://prettier.io/lib/plugins/estree.js:10:289)
    at https://prettier.io/lib/plugins/estree.js:36:14282
    at Array.every (<anonymous>)
    at https://prettier.io/lib/plugins/estree.js:36:14273
    at Array.some (<anonymous>)
    at Oi (https://prettier.io/lib/plugins/estree.js:36:14252)
    at Kr (https://prettier.io/lib/plugins/estree.js:36:14852)
    at Ta (https://prettier.io/lib/plugins/estree.js:36:58423)

Expected output:

Not exactly sure, it's an error.

Why?

This was not an error in 3.1.x.

Metadata

Metadata

Assignees

No one assigned

    Labels

    lang:javascriptIssues affecting JSlocked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.priority:highCode is printed in a way that alters the AST, breaks syntax, or is a significant regression. Urgent!

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions