Skip to content

Commit

Permalink
fix: Corrects return type of rules constructed by sizedArrayRuleConst…
Browse files Browse the repository at this point in the history
…ructor
  • Loading branch information
ryasmi committed Jan 9, 2025
1 parent b2ac749 commit a29ea54
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const [rule, InvalidValueError] = sizedArrayRuleConstructor(number, 2, 3, ruleSy

test('sizedArrayRuleConstructor rule should allow a valid array within size range', () => {
const input = [1, 2]
const output: Constrained<typeof ruleSymbol, unknown[]> = rule(input)
const output: Constrained<typeof ruleSymbol, number[]> = rule(input)
assert.deepStrictEqual(output, input)
assert.ok(InvalidValueError)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { BaseError } from 'make-error';
import { Constrained, Rule } from '../../core'
import { array } from '../../higherOrderRules/array/array'

type Result<T extends symbol> = [
Rule<Constrained<T, unknown[]>>,
type Result<Item, T extends symbol> = [
Rule<Constrained<T, Item[]>>,
typeof BaseError
]

Expand All @@ -12,7 +12,7 @@ export function sizedArrayRuleConstructor<Item, RuleSymbol extends symbol>(
minSize: number,
maxSize: number,
symbol: RuleSymbol,
): Result<RuleSymbol> {
): Result<Item, RuleSymbol> {
type SizedArray = Constrained<typeof symbol, Item[]>;
const arrayRule = array(itemRule);

Expand Down

0 comments on commit a29ea54

Please sign in to comment.