Skip to content

Commit ff9fb70

Browse files
committed
fix(backend): optional chaining
1 parent 1e2b916 commit ff9fb70

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

packages/common/src/structure-information/classes/StructureInformation.class.ts

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,27 @@ export class StructureInformation implements AppEntity {
1717
public createdAt?: Date;
1818
public updatedAt?: Date;
1919
public version?: number;
20-
constructor(options: Partial<StructureInformation>) {
21-
this.title = options.title || "";
22-
this.description = options.description || "";
23-
this.startDate = options.startDate || null;
24-
this.endDate = options.endDate || null;
25-
this.type = options.type || "other";
26-
this.createdAt = createDate(options.createdAt) ?? new Date();
27-
this.updatedAt = createDate(options.updatedAt) ?? new Date();
28-
this.createdBy = options.createdBy;
29-
this.structureId = options.structureId;
30-
this.isTemporary = options.isTemporary;
20+
constructor(options?: Partial<StructureInformation>) {
21+
this.title = options?.title || "";
22+
this.description = options?.description || "";
23+
this.startDate = options?.startDate || null;
24+
this.endDate = options?.endDate || null;
25+
this.type = options?.type || "other";
26+
this.createdAt = createDate(options?.createdAt) ?? new Date();
27+
this.updatedAt = createDate(options?.updatedAt) ?? new Date();
28+
this.createdBy = options?.createdBy;
29+
this.structureId = options?.structureId;
30+
this.isTemporary = options?.isTemporary;
3131
this.isExpired = isMessageExpired(options);
32-
this.uuid = options.uuid;
33-
this.version = options.version;
32+
this.uuid = options?.uuid;
33+
this.version = options?.version;
3434
}
3535
}
3636

3737
export function isMessageExpired(
38-
message: Partial<StructureInformation>
39-
): boolean {
38+
message?: Partial<StructureInformation>
39+
): boolean | undefined {
40+
if (!message) return undefined;
4041
if (!message.endDate || !message.startDate || !message.isTemporary)
4142
return false;
4243
const today = new Date();

0 commit comments

Comments
 (0)