Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix usage of any #27

Merged
merged 2 commits into from
Jun 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/large-falcons-breathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@neo4j/cypher-builder": minor
---

Updates CypherResult type to Record<string, unknown>, better reflecting the results of the parameters
7 changes: 4 additions & 3 deletions src/Environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ export class CypherEnvironment {
return id;
}

public getParams(): Record<string, any> {
return this.params.reduce((acc, param: Param) => {
public getParams(): Record<string, unknown> {
return this.params.reduce<Record<string, unknown>>((acc, param: Param) => {
const key = this.getReferenceId(param);
if (param.hasValue) {
acc[key] = param.value;
}
return acc;
}, {} as Record<string, any>);
}, {});
}

public addNamedParamReference(name: string, param: Param): void {
Expand Down Expand Up @@ -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);
}
}
2 changes: 1 addition & 1 deletion src/clauses/Clause.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, any> = {}): CypherResult {
public build(prefix?: string | EnvPrefix | undefined, extraParams: Record<string, unknown> = {}): CypherResult {
if (this.isRoot) {
const env = this.getEnv(prefix);
const cypher = this.getCypher(env);
Expand Down
1 change: 1 addition & 0 deletions src/clauses/utils/mixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* limitations under the License.
*/

/* eslint-disable @typescript-eslint/no-explicit-any */
import type { ClauseMixin } from "../mixins/ClauseMixin";

type ConstructorType<T> = new (...args: any[]) => T;
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export type Predicate =

export type CypherResult = {
cypher: string;
params: Record<string, string>;
params: Record<string, unknown>;
};

/** Defines the interface for a class that can be compiled into Cypher */
Expand Down
Loading