You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficcontrol.apache.org by "ocket8888 (via GitHub)" <gi...@apache.org> on 2023/07/24 21:57:51 UTC

[GitHub] [trafficcontrol] ocket8888 commented on a diff in pull request #7585: tpv2 redirect to tpv1

ocket8888 commented on code in PR #7585:
URL: https://github.com/apache/trafficcontrol/pull/7585#discussion_r1272797836


##########
experimental/traffic-portal/server.config.ts:
##########
@@ -202,6 +204,12 @@ function isConfig(c: unknown): c is ServerConfig {
 	if (typeof((c as {trafficOps: unknown}).trafficOps) !== "string") {
 		throw new Error("'trafficOps' must be a string");
 	}
+	if (!Object.prototype.hasOwnProperty.call(c, "tpv1Url")) {
+		throw new Error("'tpv1Url' is required");
+	}
+	if (typeof((c as {tpv1Url: unknown}).tpv1Url) !== "string") {
+		throw new Error("'tpv1Url' must be a string");
+	}

Review Comment:
   These blocks can be combined into a single check that doesn't need `as` if you import `hasProperty` from our utils package and use that. Probably also occurs elsewhere in the PR, and definitely in the code at large.



-- 
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: issues-unsubscribe@trafficcontrol.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org