Print declare before accessibility in class properties (#16731)
This commit is contained in:
1 parent
d973283c16
commit
02200375bc
4 files changed
+44
-1
No files matched your search
@@ -0,0 +1,19 @@
|
||||
#### Print `declare` before accessibility in class properties (#16731 by @fisker)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```tsx
|
||||
// Input
|
||||
class A {
|
||||
declare private readonly name: string;
|
||||
}
|
||||
|
||||
// Prettier stable
|
||||
class A {
|
||||
private declare readonly name: string;
|
||||
}
|
||||
|
||||
// Prettier main
|
||||
class A {
|
||||
declare private readonly name: string;
|
||||
}
|
||||
```
|
||||
@@ -231,7 +231,7 @@ function printClassProperty(path, options, print) {
|
||||
parts.push(printClassMemberDecorators(path, options, print));
|
||||
}
|
||||
|
||||
parts.push(printTypeScriptAccessibilityToken(node), printDeclareToken(path));
|
||||
parts.push(printDeclareToken(path), printTypeScriptAccessibilityToken(node));
|
||||
|
||||
if (node.static) {
|
||||
parts.push("static ");
|
||||
|
||||
@@ -88,6 +88,26 @@ class B {
|
||||
================================================================================
|
||||
`;
|
||||
|
||||
exports[`declare-field.ts format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["typescript"]
|
||||
printWidth: 80
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
class A {
|
||||
declare private readonly name: string;
|
||||
private declare readonly name2: string;
|
||||
}
|
||||
|
||||
=====================================output=====================================
|
||||
class A {
|
||||
declare private readonly name: string;
|
||||
declare private readonly name2: string;
|
||||
}
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
|
||||
exports[`declare-readonly-field-initializer.ts format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["typescript"]
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
class A {
|
||||
declare private readonly name: string;
|
||||
private declare readonly name2: string;
|
||||
}
|
||||
Reference in new issue
Block a user