-
Notifications
You must be signed in to change notification settings - Fork 22
Open
Description
Because the generic passed to run/stream/first is wrapped in a Dictionary, I cannot specify the object being returned.
For example,
const orgFromNode = (node: Node<Organization>) =>
Organization.from(node.properties);
const orgNode = await q
.matchNode('org', 'Organization')
.return('org')
.first();
return orgFromNode(orgNode);TS2345: Argument of type 'Dictionary<any>' is not assignable to parameter of type 'Node<Organization>'.
Type 'Dictionary<any>' is missing the following properties from type 'Node<Organization>': identity, labels, properties
IMO, Dictionary types are pretty worthless since you can't specify their associated keys. All keys could be any of the value types.
const record = {} as Dictionary<string | boolean | DateTime>;
record.updatedAt; // this a DateTime but TS thinks it could be a boolean or string as well
record.active; // this a boolean but TS thinks it could be a DateTime or string as wellIt would be helpful if this wrapping is removed so one can specify the actual return type. i.e.
const orgNode = await q
.matchNode('org', 'Organization')
.return('org')
.first<Node<Organization>>()And Dictionary types could still be used by users, just explicitly now.
I know this is probably considered a breaking change 🙁
On a positive note, I'm loving the library and it's design. Thanks for your hard work 🤝
Reactions are currently unavailable