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

Extra parentheses and spaces added to TypeScript #6997

Closed
David-Else opened this issue Nov 18, 2019 · 2 comments
Closed

Extra parentheses and spaces added to TypeScript #6997

David-Else opened this issue Nov 18, 2019 · 2 comments
Labels
locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting.

Comments

@David-Else
Copy link

Prettier 1.19.1
Playground link

--parser babel

Input:

class GameObject {
  constructor({
    position,
    velocity,
    Physics,
    Graphics,
    Input,
  }: {
    position: Vector2;
    velocity: Vector2;
    Physics: {
      new (): PhysicsComponent;
    };
    Graphics: {
      new (): GraphicsComponent;
    };
    Input: {
      new (): InputComponent;
    };
  }) {
    this.position = position,
    this.velocity = velocity,
    this.input = new Input();
    this.physics = new Physics();
    this.graphics = new Graphics();
  }
}

Output:

class GameObject {
  constructor({
    position,
    velocity,
    Physics,
    Graphics,
    Input
  }: {
    position: Vector2,
    velocity: Vector2,
    Physics: {
      new(): PhysicsComponent
    },
    Graphics: {
      new(): GraphicsComponent
    },
    Input: {
      new(): InputComponent
    }
  }) {
    (this.position = position),
      (this.velocity = velocity),
      (this.input = new Input());
    this.physics = new Physics();
    this.graphics = new Graphics();
  }
}

Expected behavior:

    this.position = position,
    this.velocity = velocity,
    this.input = new Input();
    this.physics = new Physics();
    this.graphics = new Graphics();
@thorn0
Copy link
Member

thorn0 commented Nov 18, 2019

Works as intended. That's how Prettier formats the comma operator. I think you used this operator instead of semicolons by mistake.

@thorn0 thorn0 closed this as completed Nov 18, 2019
@David-Else
Copy link
Author

@thorn0 You are right! Thanks :)

@lock lock bot added the locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. label Feb 16, 2020
@lock lock bot locked as resolved and limited conversation to collaborators Feb 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting.
Projects
None yet
Development

No branches or pull requests

2 participants