-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Labels
good first issueGood fist issue!Good fist issue!lang:angularIssues affecting Angular template (not general JS/TS issues used for Angular)Issues affecting Angular template (not general JS/TS issues used for Angular)lang:typescriptIssues affecting TypeScript-specific constructs (not general JS issues)Issues affecting TypeScript-specific constructs (not general JS issues)locked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.Please open a new issue and fill out the template instead of commenting.
Description
Prettier 3.2.4
Playground link
--parser babel
Input:
const template = "foobar";
@Component({
[template]: `<h1>{{ hello }}</h1>`,
})
export class AppComponent {}
Output:
const template = "foobar";
@Component({
[template]: `<h1>{{ hello }}</h1>`,
})
export class AppComponent {}
Expected output:
const template = "foobar";
@Component({
[template]: `<h1>{{ hello }}</h1>`,
})
export class AppComponent {}
Why?
Prettier formats the content of the template
field in Angular's @Component
decorator as HTML. However, it now also formats the content of a different field named template
as HTML. This isn't expected.
I think adding !node.computed
to
prettier/src/language-js/embed/utils.js
Lines 47 to 51 in 4b1965a
(node, name) => | |
isObjectProperty(node) && | |
node.key.type === "Identifier" && | |
node.key.name === "template" && | |
name === "value", |
Metadata
Metadata
Assignees
Labels
good first issueGood fist issue!Good fist issue!lang:angularIssues affecting Angular template (not general JS/TS issues used for Angular)Issues affecting Angular template (not general JS/TS issues used for Angular)lang:typescriptIssues affecting TypeScript-specific constructs (not general JS issues)Issues affecting TypeScript-specific constructs (not general JS issues)locked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.Please open a new issue and fill out the template instead of commenting.