joshsh commented on code in PR #2599:
URL: https://github.com/apache/tinkerpop/pull/2599#discussion_r1632159247
##########
gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/graph.ts:
##########
@@ -43,27 +42,32 @@ export class Graph {
}
}
-class Element {
+class Element<TLabel extends string = string, TId = any> {
constructor(
- readonly id: string,
- readonly label: string,
+ readonly id: TId,
+ readonly label: TLabel,
) {}
/**
* Compares this instance to another and determines if they can be
considered as equal.
- * @param {Element} other
- * @returns {boolean}
*/
- equals(other: any) {
+ equals(other: any): boolean {
return other instanceof Element && this.id === other.id;
}
}
-export class Vertex<T extends Record<string, any> = Record<string, any>>
extends Element {
+export class Vertex<
+ TLabel extends string = string,
+ TProperties extends Record<string, any> = Record<string, any>,
Review Comment:
This looks like good work, but I don't know TypeScript. Quick question to
get oriented: is optionality in property types supported, and if so, how? I.e.
can you declare a certain vertex type to have a mandatory string-valued "name"
property, and another vertex type to have an optional string-valued "name"
property?
--
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]