diff --git a/.changeset/large-falcons-breathe.md b/.changeset/large-falcons-breathe.md new file mode 100644 index 00000000..bc48e6cb --- /dev/null +++ b/.changeset/large-falcons-breathe.md @@ -0,0 +1,5 @@ +--- +"@neo4j/cypher-builder": minor +--- + +Updates CypherResult type to Record, better reflecting the results of the parameters diff --git a/src/Environment.ts b/src/Environment.ts index d46bc5ea..0d4960e3 100644 --- a/src/Environment.ts +++ b/src/Environment.ts @@ -60,14 +60,14 @@ export class CypherEnvironment { return id; } - public getParams(): Record { - return this.params.reduce((acc, param: Param) => { + public getParams(): Record { + return this.params.reduce>((acc, param: Param) => { const key = this.getReferenceId(param); if (param.hasValue) { acc[key] = param.value; } return acc; - }, {} as Record); + }, {}); } public addNamedParamReference(name: string, param: Param): void { @@ -112,6 +112,7 @@ export class CypherEnvironment { } private isNamedReference(ref: Reference | NamedReference): ref is NamedReference { + // eslint-disable-next-line @typescript-eslint/no-explicit-any return Boolean((ref as any).id); } } diff --git a/src/clauses/Clause.ts b/src/clauses/Clause.ts index 82e3f286..d86b5afd 100644 --- a/src/clauses/Clause.ts +++ b/src/clauses/Clause.ts @@ -31,7 +31,7 @@ const customInspectSymbol = Symbol.for("nodejs.util.inspect.custom"); */ export abstract class Clause extends CypherASTNode { /** Compiles a clause into Cypher and params */ - public build(prefix?: string | EnvPrefix | undefined, extraParams: Record = {}): CypherResult { + public build(prefix?: string | EnvPrefix | undefined, extraParams: Record = {}): CypherResult { if (this.isRoot) { const env = this.getEnv(prefix); const cypher = this.getCypher(env); diff --git a/src/clauses/utils/mixin.ts b/src/clauses/utils/mixin.ts index 9851fcc5..fedd4978 100644 --- a/src/clauses/utils/mixin.ts +++ b/src/clauses/utils/mixin.ts @@ -17,6 +17,7 @@ * limitations under the License. */ +/* eslint-disable @typescript-eslint/no-explicit-any */ import type { ClauseMixin } from "../mixins/ClauseMixin"; type ConstructorType = new (...args: any[]) => T; diff --git a/src/types.ts b/src/types.ts index 98cbb96b..e51435f4 100644 --- a/src/types.ts +++ b/src/types.ts @@ -72,7 +72,7 @@ export type Predicate = export type CypherResult = { cypher: string; - params: Record; + params: Record; }; /** Defines the interface for a class that can be compiled into Cypher */