fix(ts-formatter): handle optional property (fixes
MODIFY
internal/formatter/builders/js/classes/JSClassProperty.ts
internal/formatter/builders/js/classes/JSClassProperty.ts
@@ -23,6 +23,10 @@ export default function JSClassProperty(
builder.tokenize(node.key, node),
];
+ if (node.meta.optional) {
+ tokens.push("?");
+ }
+
if (builder.options.typeAnnotations && node.definite) {
tokens.push("!");
}

ADD
internal/formatter/test-fixtures/typescript/classProperty/input.ts
+class Foo {
+ private foo?: string;
+}

fix(ts-formatter): handle optional property (fixes #1351) (#1365)