-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
[Typescript] Prettier removes question mark from optional computed class property #6569
Copy link
Copy link
Closed
Copy link
Labels
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.scope:dependencyIssues that cannot be solved inside Prettier itself, and must be fixed in a dependencyIssues that cannot be solved inside Prettier itself, and must be fixed in a dependency
Description
Prettier 1.18.2
Playground link
--parser typescriptInput:
const bar = 'bar';
class Foo {
[bar]?;
[1]?;
['baz']?;
}Output:
const bar = "bar";
class Foo {
[bar];
[1]?;
["baz"]?;
}Expected behavior:
Prettier should preserve ? in output. Expected output:
const bar = "bar";
class Foo {
[bar]?;
[1]?;
["baz"]?;
}This only happens when the computed property is a variable.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
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.scope:dependencyIssues that cannot be solved inside Prettier itself, and must be fixed in a dependencyIssues that cannot be solved inside Prettier itself, and must be fixed in a dependency