From cd5bedbb65a65b3e3252949ef260158c863f4e05 Mon Sep 17 00:00:00 2001 From: Taras Mankovski Date: Sat, 6 Apr 2019 15:46:26 -0400 Subject: [PATCH] Added remaining array transitions --- types/microstates.d.ts | 4 ++++ types/types.test.ts | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/types/microstates.d.ts b/types/microstates.d.ts index 0e63030c..45296f3c 100644 --- a/types/microstates.d.ts +++ b/types/microstates.d.ts @@ -56,6 +56,10 @@ declare module "microstates" { slice(start?: number, end?: number): ArrayType sort(fn: (a: any, b: any) => number): ArrayType filter(fn: (member: T) => boolean): ArrayType + map(fn: (member: T) => T): ArrayType + remove(item: any): ArrayType + clear(): ArrayType + initialize(value: any): ArrayType } interface ArrayTypeConstructor { diff --git a/types/types.test.ts b/types/types.test.ts index fdb93441..d684370d 100644 --- a/types/types.test.ts +++ b/types/types.test.ts @@ -117,4 +117,24 @@ describe('ArrayType', () => { a.filter((item) => (item.state + '!!!') === 'hello!!!') ) }); + it('has map transition that returns ArrayType', () => { + expectType>( + a.map(item => item.concat('!!!')) + ) + }); + it('has remove transition that returns ArrayType', () => { + expectType>( + a.remove('hello') + ) + }); + it('has clear transition that returns ArrayType', () => { + expectType>( + a.clear() + ) + }); + it('has initialize transition taht returns ArrayType', () => { + expectType>( + a.initialize('foo') + ) + }); });