tien commented on code in PR #2599:
URL: https://github.com/apache/tinkerpop/pull/2599#discussion_r1636137624
##########
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,
Review Comment:
TypeScript string literal are kinda like enum in Java or C#, so for example:
```ts
type LiteralPerson = Vertex<"person", { name: string; age: number }>;
type LoosePerson = Vertex<string, { name: string; age: number }>;
let person1: LiteralPerson // person1.label will have a const type of
`"person"`
let person2: LoosePerson // person2.label will instead only be typed as
`string`
```
source:
https://www.typescriptlang.org/docs/handbook/literal-types.html#string-literal-types
--
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]