From 007749835f354be8f752b417c140757c1911cbb5 Mon Sep 17 00:00:00 2001 From: gcanti Date: Mon, 6 Jan 2020 12:20:48 +0100 Subject: [PATCH] Bug Fix: fix Record.updateAt and Record.modifyAt signatures --- docs/modules/Record.ts.md | 4 ++-- dtslint/ts3.5/Record.ts | 18 ++++++++++++++++++ src/Record.ts | 4 ++-- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/docs/modules/Record.ts.md b/docs/modules/Record.ts.md index 0b3b1d365..14d751ef8 100644 --- a/docs/modules/Record.ts.md +++ b/docs/modules/Record.ts.md @@ -445,7 +445,7 @@ Added in v2.0.0 **Signature** ```ts -export function modifyAt(k: K, f: (a: A) => A): (r: Record) => Option> { ... } +export function modifyAt(k: string, f: (a: A) => A): (r: Record) => Option> { ... } ``` Added in v2.0.0 @@ -648,7 +648,7 @@ Added in v2.0.0 **Signature** ```ts -export function updateAt(k: K, a: A): (r: Record) => Option> { ... } +export function updateAt(k: string, a: A): (r: Record) => Option> { ... } ``` Added in v2.0.0 diff --git a/dtslint/ts3.5/Record.ts b/dtslint/ts3.5/Record.ts index 4160ec891..0d8ca5967 100644 --- a/dtslint/ts3.5/Record.ts +++ b/dtslint/ts3.5/Record.ts @@ -1,4 +1,6 @@ +import { pipe } from '../../src/pipeable' import * as R from '../../src/Record' +import { identity } from '../../src/function' declare const dictionaryString: { [key: string]: number } declare const recordString: Record @@ -19,3 +21,19 @@ if (R.hasOwnProperty(keyString, recordString)) { if (R.hasOwnProperty(keyString, recordStringEnum)) { keyString // $ExpectType "a" | "b" } + +// +// updateAt +// + +pipe(dictionaryString, R.updateAt('a', 3)) // $ExpectType Option> +pipe(recordString, R.updateAt('a', 3)) // $ExpectType Option> +pipe(recordStringEnum, R.updateAt('a', 3)) // $ExpectType Option> + +// +// modifyAt +// + +pipe(dictionaryString, R.modifyAt('a', identity)) // $ExpectType Option> +pipe(recordString, R.modifyAt('a', identity)) // $ExpectType Option> +pipe(recordStringEnum, R.modifyAt('a', identity)) // $ExpectType Option> diff --git a/src/Record.ts b/src/Record.ts index 57d38c22e..fd1c3d25d 100644 --- a/src/Record.ts +++ b/src/Record.ts @@ -170,7 +170,7 @@ export function deleteAt(k: string): (r: Record) => Record(k: K, a: A): (r: Record) => Option> { +export function updateAt(k: string, a: A): (r: Record) => Option> { return r => { if (!hasOwnProperty(k, r)) { return none @@ -187,7 +187,7 @@ export function updateAt(k: K, a: A): (r: Record) => /** * @since 2.0.0 */ -export function modifyAt(k: K, f: (a: A) => A): (r: Record) => Option> { +export function modifyAt(k: string, f: (a: A) => A): (r: Record) => Option> { return r => { if (!hasOwnProperty(k, r)) { return none