Skip to content

Commit 2cbd1de

Browse files
committed
refactor: some of the statements are redundant. It is not necessary to write to write only properties.
1 parent 38be7d8 commit 2cbd1de

File tree

1 file changed

+7
-18
lines changed

1 file changed

+7
-18
lines changed

src/TypeScriptGenerator.ts

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,9 @@ function makeProp(
150150
)
151151
);
152152
}
153-
const typeProperty = objectTypeProperty(key, value);
154-
if (conditional) {
155-
// @ts-ignore
156-
typeProperty.questionToken = ts.factory.createToken(
157-
ts.SyntaxKind.QuestionToken
158-
);
159-
}
153+
const typeProperty = objectTypeProperty(key, value, {
154+
optional: conditional,
155+
});
160156

161157
return typeProperty;
162158
}
@@ -559,10 +555,7 @@ function createVisitor(
559555
ts.factory.createTypeReferenceNode(dataTypeName, undefined),
560556
{ optional: true }
561557
);
562-
// @ts-ignore
563-
refTypeDataProperty.questionToken = ts.factory.createToken(
564-
ts.SyntaxKind.QuestionToken
565-
);
558+
566559
const refTypeFragmentRefProperty = objectTypeProperty(
567560
FRAGMENT_REFS,
568561
ts.factory.createTypeReferenceNode(FRAGMENT_REFS_TYPE_NAME, [
@@ -752,13 +745,9 @@ function makeRawResponseProp(
752745
);
753746
}
754747

755-
const typeProperty = objectTypeProperty(key, value);
756-
if (conditional) {
757-
// @ts-ignore
758-
typeProperty.questionToken = ts.factory.createToken(
759-
ts.SyntaxKind.QuestionToken
760-
);
761-
}
748+
const typeProperty = objectTypeProperty(key, value, {
749+
optional: conditional,
750+
});
762751

763752
return typeProperty;
764753
}

0 commit comments

Comments
 (0)