Skip to content

Commit a23d857

Browse files
author
Iurii Golovinskii
committed
[FE][Part 2] fixed bug in replacePropertyInChangesSummary
1 parent 23e21d1 commit a23d857

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

src/utils/transformToDto.ts

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ export function convertDtoFieldOperationTypes<
168168
origin,
169169
override,
170170
}: OptionDiffReplacer = { origin: SEMI_BREAKING_CHANGE_TYPE, override: risky }): OperationType<J>[] {
171-
return operationTypes.map((type) => {
171+
return operationTypes?.map((type) => {
172172
return {
173173
...type,
174174
changesSummary: replacePropertyInChangesSummary<T, J>(type.changesSummary, {
@@ -194,15 +194,22 @@ export function replacePropertyInChangesSummary<
194194
origin: SEMI_BREAKING_CHANGE_TYPE,
195195
override: risky,
196196
}): ChangeSummary<J> {
197-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
198-
// @ts-ignore
199-
obj[override] = obj[origin]
200-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
201-
// @ts-ignore
202-
delete obj[origin]
203-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
204-
// @ts-ignore
205-
return obj
197+
if (Object.prototype.hasOwnProperty.call(obj, origin)) {
198+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
199+
// @ts-ignore
200+
obj[override] = obj[origin]
201+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
202+
// @ts-ignore
203+
delete obj[origin]
204+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
205+
// @ts-ignore
206+
return obj
207+
} else {
208+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
209+
// @ts-ignore
210+
return obj
211+
}
212+
206213
}
207214

208215
export type DiffTypeCompare = DiffType | DiffTypeDto

0 commit comments

Comments
 (0)