restore changes and update tests
MODIFY
packages/@romejs/js-formatter/builders/classes/ClassPrivateMethod.ts
packages/@romejs/js-formatter/builders/classes/ClassPrivateMethod.ts
* LICENSE file in the root directory of this source tree.
*/
-import {Token} from "../../tokens";
+import {Token, concat, space} from "../../tokens";
+import { Builder } from "@romejs/js-formatter";
+import { ClassPrivateMethod } from '@romejs/js-ast';
+import { printMethod } from "../utils";
-export default function ClassPrivateMethod(): Token {
- throw new Error("unimplemented");
+export default function ClassPrivateMethod(
+ builder: Builder,
+ node: ClassPrivateMethod
+): Token {
+ const printed = printMethod(builder, node);
+ if (node.meta.static === true) {
+ return concat(['static', space, printed]);
+ } else {
+ return printed;
+ }
}

MODIFY
packages/@romejs/js-formatter/builders/typescript/TSConstructorType.ts
packages/@romejs/js-formatter/builders/typescript/TSConstructorType.ts
* LICENSE file in the root directory of this source tree.
*/
-import {Token} from "../../tokens";
+import {Token, space, concat} from "../../tokens";
+import { Builder } from "@romejs/js-formatter";
+import { TSConstructorType } from '@romejs/js-ast';
-export default function TSConstructorType(): Token {
- throw new Error("unimplemented");
+export default function TSConstructorType(
+ builder: Builder,
+ node: TSConstructorType
+): Token {
+ const tokens: Array<Token> = ['new', space, builder.tokenize(node.meta, node)];
+
+ if (node.typeAnnotation) {
+ tokens.push(space, '=>', space, builder.tokenize(node.typeAnnotation, node));
+ }
+
+ return concat(tokens);
}

MODIFY
packages/@romejs/js-formatter/builders/utils.ts
packages/@romejs/js-formatter/builders/utils.ts
@@ -16,6 +16,7 @@ import {
ReturnStatement,
TSDeclareMethod,
ThrowStatement,
+ ClassPrivateMethod,
} from "@romejs/js-ast";
import {isBinary} from "@romejs/js-ast-utils";
import Builder, {BuilderMethod} from "../Builder";
@@ -86,7 +87,7 @@ export function buildThrowAndReturnStatementBuilder(
export function printMethod(
builder: Builder,
- node: TSDeclareMethod | ClassMethod | ObjectMethod,
+ node: TSDeclareMethod | ClassMethod | ObjectMethod | ClassPrivateMethod,
): Token {
const kind = node.kind;

MODIFY
packages/@romejs/js-formatter/test-fixtures/typescript/tsConstructorType/input.test.md
packages/@romejs/js-formatter/test-fixtures/typescript/tsConstructorType/input.test.md
### `Input`
```javascript
-// type Class<T> = new (...args: any) => T;
-// let d: new(x: number) => void;
+type Class<T> = new (...args: any) => T;
+let d: new(x: number) => void;
```
### `Output`
```javascript
-// type Class<T> = new (...args: any) => T;
-// let d: new(x: number) => void;
+type Class<T> = new (
+ ...args: any
+) => T;
+let d: new (x: number) => void;
```

restore changes and update tests