Skip to content

Decorator is removed when followed by an interface. #4552

@muhanadra

Description

@muhanadra

Prettier 1.12.1
Playground link

--parser typescript

Input:

import { Component, OnInit } from '@angular/core';
@Component({
  selector: 'be-list',
  templateUrl: './be-list.component.html'
})
interface MyInterface {
  id: string;
}
export class BeListComponent implements OnInit {
  constructor() {
  }
  ngOnInit() {
    this.title = 'Title';
  }
}

Output:

import { Component, OnInit } from "@angular/core";
interface MyInterface {
  id: string;
}
export class BeListComponent implements OnInit {
  constructor() {}
  ngOnInit() {
    this.title = "Title";
  }
}

Expected behavior:
While the decorator is invalid, It should not be deleted. Either format it or throw a syntax error.

import { Component, OnInit } from '@angular/core';
@Component({
  selector: 'be-list',
  templateUrl: './be-list.component.html'
})
interface MyInterface {
  id: string;
}
export class BeListComponent implements OnInit {
  constructor() {
  }
  ngOnInit() {
    this.title = 'Title';
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    lang:typescriptIssues affecting TypeScript-specific constructs (not general JS issues)locked-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!scope:dependencyIssues that cannot be solved inside Prettier itself, and must be fixed in a dependencystatus:has prIssues with an accompanying pull request. These issues will probably be fixed soon!

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy