From 3b6a311d26be9a2dbfeb912ca376eafc04903989 Mon Sep 17 00:00:00 2001 From: Jacob Logan Date: Wed, 21 Feb 2024 10:24:06 -0700 Subject: [PATCH 1/4] fix: add optional chaining --- ...studio-ui-codegen-react-forms.test.ts.snap | 22 +++++++++---------- .../studio-ui-codegen-react-forms.test.ts | 6 ++--- .../form-renderer-helper/relationship.ts | 15 +++++++++---- 3 files changed, 25 insertions(+), 18 deletions(-) diff --git a/packages/codegen-ui-react/lib/__tests__/__snapshots__/studio-ui-codegen-react-forms.test.ts.snap b/packages/codegen-ui-react/lib/__tests__/__snapshots__/studio-ui-codegen-react-forms.test.ts.snap index f0c8adf5..5d897d6a 100644 --- a/packages/codegen-ui-react/lib/__tests__/__snapshots__/studio-ui-codegen-react-forms.test.ts.snap +++ b/packages/codegen-ui-react/lib/__tests__/__snapshots__/studio-ui-codegen-react-forms.test.ts.snap @@ -32139,7 +32139,7 @@ export default function UpdateOrgForm(props) { const queryData = async () => { const record = idProp ? await DataStore.query(Org, idProp) : orgModelProp; setOrgRecord(record); - const linkedComments = record ? await record.comments.toArray() : []; + const linkedComments = record ? await record?.comments?.toArray() : []; setLinkedComments(linkedComments); }; queryData(); @@ -32759,13 +32759,13 @@ export default function UpdateCompositeDogForm(props) { : undefined; setCompositeOwner(CompositeOwnerRecord); const linkedCompositeToys = record - ? await record.CompositeToys.toArray() + ? await record?.CompositeToys?.toArray() : []; setLinkedCompositeToys(linkedCompositeToys); const linkedCompositeVets = record ? await Promise.all( ( - await record.CompositeVets.toArray() + await record?.CompositeVets?.toArray() ).map((r) => { return r.compositeVet; }) @@ -33888,7 +33888,7 @@ export default function UpdateCPKTeacherForm(props) { const linkedCPKClasses = record ? await Promise.all( ( - await record.CPKClasses.toArray() + await record?.CPKClasses?.toArray() ).map((r) => { return r.cpkClass; }) @@ -33896,7 +33896,7 @@ export default function UpdateCPKTeacherForm(props) { : []; setLinkedCPKClasses(linkedCPKClasses); const linkedCPKProjects = record - ? await record.CPKProjects.toArray() + ? await record?.CPKProjects?.toArray() : []; setLinkedCPKProjects(linkedCPKProjects); }; @@ -37257,13 +37257,13 @@ export default function UpdateCompositeDogForm(props) { : undefined; setCompositeOwner(CompositeOwnerRecord); const linkedCompositeToys = record - ? await record.CompositeToys.toArray() + ? await record?.CompositeToys?.toArray() : []; setLinkedCompositeToys(linkedCompositeToys); const linkedCompositeVets = record ? await Promise.all( ( - await record.CompositeVets.toArray() + await record?.CompositeVets?.toArray() ).map((r) => { return r.compositeVet; }) @@ -46067,7 +46067,7 @@ export default function SchoolUpdateForm(props) { ? await DataStore.query(School, idProp) : schoolModelProp; setSchoolRecord(record); - const linkedStudents = record ? await record.Students.toArray() : []; + const linkedStudents = record ? await record?.Students?.toArray() : []; setLinkedStudents(linkedStudents); }; queryData(); @@ -46643,7 +46643,7 @@ export default function SchoolUpdateForm(props) { ? await DataStore.query(School, idProp) : schoolModelProp; setSchoolRecord(record); - const linkedStudent = record ? await record.Student.toArray() : []; + const linkedStudent = record ? await record?.Student?.toArray() : []; setLinkedStudent(linkedStudent); }; queryData(); @@ -47891,7 +47891,7 @@ export default function TagUpdateForm(props) { const linkedPosts = record ? await Promise.all( ( - await record.Posts.toArray() + await record?.Posts?.toArray() ).map((r) => { return r.post; }) @@ -55329,7 +55329,7 @@ export default function UpdateDealershipForm(props) { ? await DataStore.query(Dealership, idProp) : dealershipModelProp; setDealershipRecord(record); - const linkedCars = record ? await record.cars.toArray() : []; + const linkedCars = record ? await record?.cars?.toArray() : []; setLinkedCars(linkedCars); }; queryData(); diff --git a/packages/codegen-ui-react/lib/__tests__/studio-ui-codegen-react-forms.test.ts b/packages/codegen-ui-react/lib/__tests__/studio-ui-codegen-react-forms.test.ts index e5210341..fa7e5dbc 100644 --- a/packages/codegen-ui-react/lib/__tests__/studio-ui-codegen-react-forms.test.ts +++ b/packages/codegen-ui-react/lib/__tests__/studio-ui-codegen-react-forms.test.ts @@ -159,7 +159,7 @@ describe('amplify form renderer tests', () => { expect(componentText).toContain('const postRecords = useDataStoreBinding({'); // check lazy load linked data - expect(componentText).toContain('await record.Posts.toArray()'); + expect(componentText).toContain('await record?.Posts?.toArray()'); // check custom display value is set expect(componentText).toContain('Posts: (r) => r?.title'); @@ -228,7 +228,7 @@ describe('amplify form renderer tests', () => { expect(componentText).toContain('const studentRecords = useDataStoreBinding({'); // check lazy load linked data - expect(componentText).toContain('const linkedStudents = record ? await record.Students.toArray() : [];'); + expect(componentText).toContain('const linkedStudents = record ? await record?.Students?.toArray() : [];'); // check custom display value is set expect(componentText).toContain('Students: (r) => r?.name'); @@ -257,7 +257,7 @@ describe('amplify form renderer tests', () => { expect(componentText).toContain('const studentRecords = useDataStoreBinding({'); // check lazy load linked data - expect(componentText).toContain('const linkedStudent = record ? await record.Student.toArray() : [];'); + expect(componentText).toContain('const linkedStudent = record ? await record?.Student?.toArray() : [];'); // check custom display value is set expect(componentText).toContain('Student: (r) => `${r?.name ? r?.name + " - " : ""}${r?.id}`,'); diff --git a/packages/codegen-ui-react/lib/forms/form-renderer-helper/relationship.ts b/packages/codegen-ui-react/lib/forms/form-renderer-helper/relationship.ts index 47ee653a..274e8e05 100644 --- a/packages/codegen-ui-react/lib/forms/form-renderer-helper/relationship.ts +++ b/packages/codegen-ui-react/lib/forms/form-renderer-helper/relationship.ts @@ -1233,11 +1233,13 @@ export const buildGetRelationshipModels = ( factory.createParenthesizedExpression( factory.createAwaitExpression( factory.createCallExpression( - factory.createPropertyAccessExpression( - factory.createPropertyAccessExpression( + factory.createPropertyAccessChain( + factory.createPropertyAccessChain( factory.createIdentifier('record'), + factory.createToken(SyntaxKind.QuestionDotToken), factory.createIdentifier(fieldName), ), + factory.createToken(SyntaxKind.QuestionDotToken), factory.createIdentifier('toArray'), ), undefined, @@ -1309,8 +1311,13 @@ export const buildGetRelationshipModels = ( factory.createToken(SyntaxKind.QuestionToken), factory.createAwaitExpression( factory.createCallExpression( - factory.createPropertyAccessExpression( - factory.createPropertyAccessExpression(recordIdentifier, factory.createIdentifier(fieldName)), + factory.createPropertyAccessChain( + factory.createPropertyAccessChain( + recordIdentifier, + factory.createToken(SyntaxKind.QuestionDotToken), + factory.createIdentifier(fieldName), + ), + factory.createToken(SyntaxKind.QuestionDotToken), factory.createIdentifier('toArray'), ), undefined, From 80413d471647f8e19eda5a23eefe0e7fb7828f18 Mon Sep 17 00:00:00 2001 From: Jacob Logan Date: Thu, 22 Feb 2024 12:01:33 -0700 Subject: [PATCH 2/4] fix: coalesce missing record to empty list --- ...studio-ui-codegen-react-forms.test.ts.snap | 25 +++++++++-------- .../studio-ui-codegen-react-forms.test.ts | 4 +-- .../form-renderer-helper/relationship.ts | 27 ++++++++++--------- 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/packages/codegen-ui-react/lib/__tests__/__snapshots__/studio-ui-codegen-react-forms.test.ts.snap b/packages/codegen-ui-react/lib/__tests__/__snapshots__/studio-ui-codegen-react-forms.test.ts.snap index 5d897d6a..ec9a462e 100644 --- a/packages/codegen-ui-react/lib/__tests__/__snapshots__/studio-ui-codegen-react-forms.test.ts.snap +++ b/packages/codegen-ui-react/lib/__tests__/__snapshots__/studio-ui-codegen-react-forms.test.ts.snap @@ -32139,7 +32139,8 @@ export default function UpdateOrgForm(props) { const queryData = async () => { const record = idProp ? await DataStore.query(Org, idProp) : orgModelProp; setOrgRecord(record); - const linkedComments = record ? await record?.comments?.toArray() : []; + const linkedComments = + (record && (await record.comments?.toArray())) || []; setLinkedComments(linkedComments); }; queryData(); @@ -32758,9 +32759,8 @@ export default function UpdateCompositeDogForm(props) { ? await record.CompositeOwner : undefined; setCompositeOwner(CompositeOwnerRecord); - const linkedCompositeToys = record - ? await record?.CompositeToys?.toArray() - : []; + const linkedCompositeToys = + (record && (await record.CompositeToys?.toArray())) || []; setLinkedCompositeToys(linkedCompositeToys); const linkedCompositeVets = record ? await Promise.all( @@ -33895,9 +33895,8 @@ export default function UpdateCPKTeacherForm(props) { ) : []; setLinkedCPKClasses(linkedCPKClasses); - const linkedCPKProjects = record - ? await record?.CPKProjects?.toArray() - : []; + const linkedCPKProjects = + (record && (await record.CPKProjects?.toArray())) || []; setLinkedCPKProjects(linkedCPKProjects); }; queryData(); @@ -37256,9 +37255,8 @@ export default function UpdateCompositeDogForm(props) { ? await record.CompositeOwner : undefined; setCompositeOwner(CompositeOwnerRecord); - const linkedCompositeToys = record - ? await record?.CompositeToys?.toArray() - : []; + const linkedCompositeToys = + (record && (await record.CompositeToys?.toArray())) || []; setLinkedCompositeToys(linkedCompositeToys); const linkedCompositeVets = record ? await Promise.all( @@ -46067,7 +46065,8 @@ export default function SchoolUpdateForm(props) { ? await DataStore.query(School, idProp) : schoolModelProp; setSchoolRecord(record); - const linkedStudents = record ? await record?.Students?.toArray() : []; + const linkedStudents = + (record && (await record.Students?.toArray())) || []; setLinkedStudents(linkedStudents); }; queryData(); @@ -46643,7 +46642,7 @@ export default function SchoolUpdateForm(props) { ? await DataStore.query(School, idProp) : schoolModelProp; setSchoolRecord(record); - const linkedStudent = record ? await record?.Student?.toArray() : []; + const linkedStudent = (record && (await record.Student?.toArray())) || []; setLinkedStudent(linkedStudent); }; queryData(); @@ -55329,7 +55328,7 @@ export default function UpdateDealershipForm(props) { ? await DataStore.query(Dealership, idProp) : dealershipModelProp; setDealershipRecord(record); - const linkedCars = record ? await record?.cars?.toArray() : []; + const linkedCars = (record && (await record.cars?.toArray())) || []; setLinkedCars(linkedCars); }; queryData(); diff --git a/packages/codegen-ui-react/lib/__tests__/studio-ui-codegen-react-forms.test.ts b/packages/codegen-ui-react/lib/__tests__/studio-ui-codegen-react-forms.test.ts index fa7e5dbc..5c926a70 100644 --- a/packages/codegen-ui-react/lib/__tests__/studio-ui-codegen-react-forms.test.ts +++ b/packages/codegen-ui-react/lib/__tests__/studio-ui-codegen-react-forms.test.ts @@ -228,7 +228,7 @@ describe('amplify form renderer tests', () => { expect(componentText).toContain('const studentRecords = useDataStoreBinding({'); // check lazy load linked data - expect(componentText).toContain('const linkedStudents = record ? await record?.Students?.toArray() : [];'); + expect(componentText).toContain('(record && (await record.Students?.toArray())) || [];'); // check custom display value is set expect(componentText).toContain('Students: (r) => r?.name'); @@ -257,7 +257,7 @@ describe('amplify form renderer tests', () => { expect(componentText).toContain('const studentRecords = useDataStoreBinding({'); // check lazy load linked data - expect(componentText).toContain('const linkedStudent = record ? await record?.Student?.toArray() : [];'); + expect(componentText).toContain('const linkedStudent = (record && (await record.Student?.toArray())) || [];'); // check custom display value is set expect(componentText).toContain('Student: (r) => `${r?.name ? r?.name + " - " : ""}${r?.id}`,'); diff --git a/packages/codegen-ui-react/lib/forms/form-renderer-helper/relationship.ts b/packages/codegen-ui-react/lib/forms/form-renderer-helper/relationship.ts index 274e8e05..2dc20ec4 100644 --- a/packages/codegen-ui-react/lib/forms/form-renderer-helper/relationship.ts +++ b/packages/codegen-ui-react/lib/forms/form-renderer-helper/relationship.ts @@ -1306,25 +1306,26 @@ export const buildGetRelationshipModels = ( undefined, dataApi === 'GraphQL' ? graphqlLinkedRecordsFallback(fieldName) - : factory.createConditionalExpression( - recordIdentifier, - factory.createToken(SyntaxKind.QuestionToken), - factory.createAwaitExpression( - factory.createCallExpression( - factory.createPropertyAccessChain( + : factory.createBinaryExpression( + factory.createBinaryExpression( + recordIdentifier, + factory.createToken(SyntaxKind.AmpersandAmpersandToken), + factory.createAwaitExpression( + factory.createCallExpression( factory.createPropertyAccessChain( - recordIdentifier, + factory.createPropertyAccessExpression( + recordIdentifier, + factory.createIdentifier(fieldName), + ), factory.createToken(SyntaxKind.QuestionDotToken), - factory.createIdentifier(fieldName), + factory.createIdentifier('toArray'), ), - factory.createToken(SyntaxKind.QuestionDotToken), - factory.createIdentifier('toArray'), + undefined, + [], ), - undefined, - [], ), ), - factory.createToken(SyntaxKind.ColonToken), + factory.createToken(SyntaxKind.BarBarToken), factory.createArrayLiteralExpression([], false), ), ), From 8298ab19dde04dcadf6b4c1994505701c5c9a175 Mon Sep 17 00:00:00 2001 From: Jacob Logan Date: Thu, 22 Feb 2024 12:39:06 -0700 Subject: [PATCH 3/4] fix: coalesce missing record to empty array --- ...studio-ui-codegen-react-forms.test.ts.snap | 34 +++++++++---------- .../studio-ui-codegen-react-forms.test.ts | 2 +- .../form-renderer-helper/relationship.ts | 30 ++++++++++------ 3 files changed, 36 insertions(+), 30 deletions(-) diff --git a/packages/codegen-ui-react/lib/__tests__/__snapshots__/studio-ui-codegen-react-forms.test.ts.snap b/packages/codegen-ui-react/lib/__tests__/__snapshots__/studio-ui-codegen-react-forms.test.ts.snap index ec9a462e..c66da6f5 100644 --- a/packages/codegen-ui-react/lib/__tests__/__snapshots__/studio-ui-codegen-react-forms.test.ts.snap +++ b/packages/codegen-ui-react/lib/__tests__/__snapshots__/studio-ui-codegen-react-forms.test.ts.snap @@ -32764,11 +32764,11 @@ export default function UpdateCompositeDogForm(props) { setLinkedCompositeToys(linkedCompositeToys); const linkedCompositeVets = record ? await Promise.all( - ( - await record?.CompositeVets?.toArray() - ).map((r) => { - return r.compositeVet; - }) + ((record && (await record.CompositeVets?.toArray())) || []).map( + (r) => { + return r.compositeVet; + } + ) ) : []; setLinkedCompositeVets(linkedCompositeVets); @@ -33887,11 +33887,11 @@ export default function UpdateCPKTeacherForm(props) { setCPKStudent(CPKStudentRecord); const linkedCPKClasses = record ? await Promise.all( - ( - await record?.CPKClasses?.toArray() - ).map((r) => { - return r.cpkClass; - }) + ((record && (await record.CPKClasses?.toArray())) || []).map( + (r) => { + return r.cpkClass; + } + ) ) : []; setLinkedCPKClasses(linkedCPKClasses); @@ -37260,11 +37260,11 @@ export default function UpdateCompositeDogForm(props) { setLinkedCompositeToys(linkedCompositeToys); const linkedCompositeVets = record ? await Promise.all( - ( - await record?.CompositeVets?.toArray() - ).map((r) => { - return r.compositeVet; - }) + ((record && (await record.CompositeVets?.toArray())) || []).map( + (r) => { + return r.compositeVet; + } + ) ) : []; setLinkedCompositeVets(linkedCompositeVets); @@ -47889,9 +47889,7 @@ export default function TagUpdateForm(props) { setTagRecord(record); const linkedPosts = record ? await Promise.all( - ( - await record?.Posts?.toArray() - ).map((r) => { + ((record && (await record.Posts?.toArray())) || []).map((r) => { return r.post; }) ) diff --git a/packages/codegen-ui-react/lib/__tests__/studio-ui-codegen-react-forms.test.ts b/packages/codegen-ui-react/lib/__tests__/studio-ui-codegen-react-forms.test.ts index 5c926a70..ffeb34f4 100644 --- a/packages/codegen-ui-react/lib/__tests__/studio-ui-codegen-react-forms.test.ts +++ b/packages/codegen-ui-react/lib/__tests__/studio-ui-codegen-react-forms.test.ts @@ -159,7 +159,7 @@ describe('amplify form renderer tests', () => { expect(componentText).toContain('const postRecords = useDataStoreBinding({'); // check lazy load linked data - expect(componentText).toContain('await record?.Posts?.toArray()'); + expect(componentText).toContain('((record && (await record.Posts?.toArray())) || []).map'); // check custom display value is set expect(componentText).toContain('Posts: (r) => r?.title'); diff --git a/packages/codegen-ui-react/lib/forms/form-renderer-helper/relationship.ts b/packages/codegen-ui-react/lib/forms/form-renderer-helper/relationship.ts index 2dc20ec4..c1b8aee8 100644 --- a/packages/codegen-ui-react/lib/forms/form-renderer-helper/relationship.ts +++ b/packages/codegen-ui-react/lib/forms/form-renderer-helper/relationship.ts @@ -1231,20 +1231,28 @@ export const buildGetRelationshipModels = ( factory.createCallExpression( factory.createPropertyAccessExpression( factory.createParenthesizedExpression( - factory.createAwaitExpression( - factory.createCallExpression( - factory.createPropertyAccessChain( - factory.createPropertyAccessChain( - factory.createIdentifier('record'), - factory.createToken(SyntaxKind.QuestionDotToken), - factory.createIdentifier(fieldName), + factory.createBinaryExpression( + factory.createBinaryExpression( + factory.createIdentifier('record'), + factory.createToken(SyntaxKind.AmpersandAmpersandToken), + factory.createAwaitExpression( + factory.createCallChain( + factory.createPropertyAccessChain( + factory.createPropertyAccessExpression( + factory.createIdentifier('record'), + factory.createIdentifier(fieldName), + ), + factory.createToken(SyntaxKind.QuestionDotToken), + factory.createIdentifier('toArray'), + ), + undefined, + undefined, + [], ), - factory.createToken(SyntaxKind.QuestionDotToken), - factory.createIdentifier('toArray'), ), - undefined, - [], ), + factory.createToken(SyntaxKind.BarBarToken), + factory.createArrayLiteralExpression([], false), ), ), factory.createIdentifier('map'), From 7bf37d0808ab2de851bbdecd44a5fd7ba60a0b62 Mon Sep 17 00:00:00 2001 From: Jacob Logan Date: Thu, 22 Feb 2024 12:59:09 -0700 Subject: [PATCH 4/4] fix: remove unneeded checks --- ...studio-ui-codegen-react-forms.test.ts.snap | 26 +++++++------------ .../studio-ui-codegen-react-forms.test.ts | 2 +- .../form-renderer-helper/relationship.ts | 26 ++++++++----------- 3 files changed, 22 insertions(+), 32 deletions(-) diff --git a/packages/codegen-ui-react/lib/__tests__/__snapshots__/studio-ui-codegen-react-forms.test.ts.snap b/packages/codegen-ui-react/lib/__tests__/__snapshots__/studio-ui-codegen-react-forms.test.ts.snap index c66da6f5..714bb952 100644 --- a/packages/codegen-ui-react/lib/__tests__/__snapshots__/studio-ui-codegen-react-forms.test.ts.snap +++ b/packages/codegen-ui-react/lib/__tests__/__snapshots__/studio-ui-codegen-react-forms.test.ts.snap @@ -32764,11 +32764,9 @@ export default function UpdateCompositeDogForm(props) { setLinkedCompositeToys(linkedCompositeToys); const linkedCompositeVets = record ? await Promise.all( - ((record && (await record.CompositeVets?.toArray())) || []).map( - (r) => { - return r.compositeVet; - } - ) + ((await record.CompositeVets?.toArray()) || []).map((r) => { + return r.compositeVet; + }) ) : []; setLinkedCompositeVets(linkedCompositeVets); @@ -33887,11 +33885,9 @@ export default function UpdateCPKTeacherForm(props) { setCPKStudent(CPKStudentRecord); const linkedCPKClasses = record ? await Promise.all( - ((record && (await record.CPKClasses?.toArray())) || []).map( - (r) => { - return r.cpkClass; - } - ) + ((await record.CPKClasses?.toArray()) || []).map((r) => { + return r.cpkClass; + }) ) : []; setLinkedCPKClasses(linkedCPKClasses); @@ -37260,11 +37256,9 @@ export default function UpdateCompositeDogForm(props) { setLinkedCompositeToys(linkedCompositeToys); const linkedCompositeVets = record ? await Promise.all( - ((record && (await record.CompositeVets?.toArray())) || []).map( - (r) => { - return r.compositeVet; - } - ) + ((await record.CompositeVets?.toArray()) || []).map((r) => { + return r.compositeVet; + }) ) : []; setLinkedCompositeVets(linkedCompositeVets); @@ -47889,7 +47883,7 @@ export default function TagUpdateForm(props) { setTagRecord(record); const linkedPosts = record ? await Promise.all( - ((record && (await record.Posts?.toArray())) || []).map((r) => { + ((await record.Posts?.toArray()) || []).map((r) => { return r.post; }) ) diff --git a/packages/codegen-ui-react/lib/__tests__/studio-ui-codegen-react-forms.test.ts b/packages/codegen-ui-react/lib/__tests__/studio-ui-codegen-react-forms.test.ts index ffeb34f4..1a683ba0 100644 --- a/packages/codegen-ui-react/lib/__tests__/studio-ui-codegen-react-forms.test.ts +++ b/packages/codegen-ui-react/lib/__tests__/studio-ui-codegen-react-forms.test.ts @@ -159,7 +159,7 @@ describe('amplify form renderer tests', () => { expect(componentText).toContain('const postRecords = useDataStoreBinding({'); // check lazy load linked data - expect(componentText).toContain('((record && (await record.Posts?.toArray())) || []).map'); + expect(componentText).toContain('((await record.Posts?.toArray()) || []).map((r)'); // check custom display value is set expect(componentText).toContain('Posts: (r) => r?.title'); diff --git a/packages/codegen-ui-react/lib/forms/form-renderer-helper/relationship.ts b/packages/codegen-ui-react/lib/forms/form-renderer-helper/relationship.ts index c1b8aee8..6add953e 100644 --- a/packages/codegen-ui-react/lib/forms/form-renderer-helper/relationship.ts +++ b/packages/codegen-ui-react/lib/forms/form-renderer-helper/relationship.ts @@ -1232,23 +1232,19 @@ export const buildGetRelationshipModels = ( factory.createPropertyAccessExpression( factory.createParenthesizedExpression( factory.createBinaryExpression( - factory.createBinaryExpression( - factory.createIdentifier('record'), - factory.createToken(SyntaxKind.AmpersandAmpersandToken), - factory.createAwaitExpression( - factory.createCallChain( - factory.createPropertyAccessChain( - factory.createPropertyAccessExpression( - factory.createIdentifier('record'), - factory.createIdentifier(fieldName), - ), - factory.createToken(SyntaxKind.QuestionDotToken), - factory.createIdentifier('toArray'), + factory.createAwaitExpression( + factory.createCallChain( + factory.createPropertyAccessChain( + factory.createPropertyAccessExpression( + factory.createIdentifier('record'), + factory.createIdentifier(fieldName), ), - undefined, - undefined, - [], + factory.createToken(SyntaxKind.QuestionDotToken), + factory.createIdentifier('toArray'), ), + undefined, + undefined, + [], ), ), factory.createToken(SyntaxKind.BarBarToken),