Update types/seamless-immutable/index.d.ts according to suggestions

This commit is contained in:
Paul Huynh
2019-01-16 00:01:09 +11:00
parent ba96b0832c
commit c304d07299
2 changed files with 5 additions and 2 deletions

View File

@@ -96,7 +96,7 @@ declare namespace SeamlessImmutable {
/** New methods added by seamless-immutable. */
interface Additions<T> {
asMutable(opts?: AsMutableOptions): T[];
asObject(toKeyValue: (item: T) => [string, any]): Immutable<object>;
asObject<U extends object = {}, K extends keyof U = keyof U>(toKeyValue: (item: T) => [K, U[K]]): Immutable<U>;
flatMap<TTarget>(mapFunction: (item: T) => TTarget): Immutable<TTarget extends any[] ? TTarget : TTarget[]>;
}

View File

@@ -155,7 +155,10 @@ interface ExtendedUser extends User {
);
// asObject
const arrayToObject1: Immutable.Immutable<object> = array.asObject((value) => [value.toString(), value]);
interface ArrayToObjectResult {
theFirstName: string;
}
const arrayToObject1: Immutable.Immutable<ArrayToObjectResult> = array.asObject<ArrayToObjectResult>((value) => ['theFirstName', value.firstName]);
}
//