From cfb62c32ccd9791024012545b707777ad3cd8c09 Mon Sep 17 00:00:00 2001 From: James Ferguson Date: Tue, 11 Jun 2019 21:22:53 +1000 Subject: [PATCH] fix(Skip, Limit): make skip and limit only accept number amounts Change the type signature for both skip and limit to prevent them from accepting a string argument. While passing in a string would still functionally work, it is probably a bug as argument only makes sense with a numeric value. BREAKING CHANGE: The type of skip and limit clauses no longer accept a string. This will only effect typescript users, there is no breaking change for javascript users. --- src/builder.ts | 4 ++-- src/clauses/limit.ts | 2 +- src/clauses/skip.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/builder.ts b/src/builder.ts index 081a0845..29b7b387 100644 --- a/src/builder.ts +++ b/src/builder.ts @@ -299,7 +299,7 @@ export abstract class Builder extends SetBlock { * @param {string | number} amount * @returns {Q} */ - limit(amount: string | number) { + limit(amount: number) { return this.continueChainClause(new Limit(amount)); } @@ -630,7 +630,7 @@ export abstract class Builder extends SetBlock { * @param {string | number} amount * @returns {Q} */ - skip(amount: string | number) { + skip(amount: number) { return this.continueChainClause(new Skip(amount)); } diff --git a/src/clauses/limit.ts b/src/clauses/limit.ts index 8f087825..ff756a93 100644 --- a/src/clauses/limit.ts +++ b/src/clauses/limit.ts @@ -4,7 +4,7 @@ import { Parameter } from '../parameter-bag'; export class Limit extends Clause { protected amountParam: Parameter; - constructor(public amount: number | string) { + constructor(public amount: number) { super(); this.amountParam = this.addParam(amount, 'limitCount'); } diff --git a/src/clauses/skip.ts b/src/clauses/skip.ts index 94532483..aad81d78 100644 --- a/src/clauses/skip.ts +++ b/src/clauses/skip.ts @@ -3,7 +3,7 @@ import { Clause } from '../clause'; export class Skip extends Clause { protected amountParam; - constructor(public amount: number | string) { + constructor(public amount: number) { super(); this.amountParam = this.addParam(amount, 'skipCount'); }