Skip to content

Parentheses for closure compiler type casting not handled well #4124

@roelkok

Description

@roelkok

Prettier 1.11.1
Playground link

Input:

/** @type {Object} */(myObject.property).someProp = true;
(/** @type {Object} */(myObject.property)).someProp = true;

const prop = /** @type {Object} */(myObject.property).someProp;

Output:

/** @type {Object} */ myObject.property.someProp = true;
/** @type {Object} */ (myObject.property).someProp = true;

const prop = /** @type {Object} */ (myObject.property.someProp);

Second Output:

/** @type {Object} */ myObject.property.someProp = true;
/** @type {Object} */ myObject.property.someProp = true;

const prop = /** @type {Object} */ (myObject.property.someProp);

Expected behavior:

The parentheses should be kept as per #2484
Also I would expect the prettier output not to be different for consecutive parsings. Now the second line of the input above gets rewritten to the first one and eventually without parentheses at all.

In the last case of the output above, the parentheses are maintained, but the closing one is moved to the back.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:commentsIssues with how Prettier prints commentslang:javascriptIssues affecting JSlocked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions