Skip to content

Commit 67dcf9b

Browse files
author
naman-contentstack
committed
updated case for refs without the flag
1 parent dd3b2a9 commit 67dcf9b

2 files changed

Lines changed: 4 additions & 7 deletions

File tree

src/generateTS/factory.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -551,11 +551,8 @@ export default function (userOptions: TSGenOptions) {
551551

552552
return `${types}[]`;
553553
}
554-
555-
const baseType =
556-
references.length === 1 ? references[0] : references.join(" | ");
557-
558-
return `${baseType}[]`;
554+
const baseUnion = references.join(" | ");
555+
return `(${baseUnion})[]`;
559556
}
560557

561558
function type_reference(field: ContentstackTypes.Field) {

tests/unit/tsgen/references.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ describe("references", () => {
4141
_version?: number;
4242
title: string;
4343
url: string;
44-
single_reference: IReferenceChild[];
45-
multiple_reference?: IReferenceChild | IBoolean | IBuiltinExample[];
44+
single_reference: (IReferenceChild)[];
45+
multiple_reference?: (IReferenceChild | IBoolean | IBuiltinExample)[];
4646
}"
4747
`);
4848
});

0 commit comments

Comments
 (0)