gbkannan89 commented on code in PR #7358:
URL: https://github.com/apache/trafficcontrol/pull/7358#discussion_r1168247090
##########
experimental/traffic-portal/src/app/api/testing/server.service.ts:
##########
@@ -302,4 +317,55 @@ export class ServerService {
srv.statusId = status.id;
srv.offlineReason = offlineReason ?? null;
}
+
+ /**
+ * Creates a status.
+ *
+ * @param status The status details (name & description) to create.
+ * @returns The status as created and returned by the API.
+ */
+ public async createStatus(status: RequestStatus):
Promise<ResponseStatus> {
+ const newStatus = {
+ ...status,
+ id: ++this.statusIdCounter,
+ lastUpdated: new Date()
+ } as { description: string; id: number; lastUpdated: Date;
name: string };
Review Comment:
"Argument of type '{ id: number; lastUpdated: Date; description?: string |
null | undefined; name: string; }'
is not assignable to parameter of type '{ description: string; id: number;
lastUpdated: Date; name: string; }'.
Types of property 'description' are incompatible. Type 'string | null |
undefined'is not assignable to type 'string'.
Type 'undefined' is not assignable to type 'string'."
Existing Solution: am trying to redefine object model with description as
string for the mock data,
Alternative solution: either we can edit the model or we can use the
non-null assertion operator to solve the error
eg: const newStatus = {
description: status.description!,
id: ++this.statusIdCounter,
lastUpdated: new Date(),
name: status.name
};
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]