When passing a generic to query.run() it does not properly type the returned value. It's typed as a Dictionary[], but when I try to access one of its elements it's not compatible with the previous given type.
import { Connection, node, Node } from 'cypher-query-builder';
type UserNode = Node<{
email: string;
}>;
//
export class UserRepo implements IUserRepo {
// ...
async findUserByEmail(email: string): Promise<User | null> {
const query = this.cypher.match([node('user', 'User', { email })]);
const rawUser = await query.run<UserNode>();
// TYPED AS: Dictionary<UserNode>[]
return UserMapper.toDomain(rawUser[0].properties);
// rawUser[0].properties is typed as any
}
}
When passing a generic to query.run() it does not properly type the returned value. It's typed as a Dictionary[], but when I try to access one of its elements it's not compatible with the previous given type.