mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
seamless-immutable - add static asMutable method to type (#44284)
* seamless-immutable - add static asMutable method to type * remove inadvertent seamless tgz
This commit is contained in:
parent
eb7ec52c01
commit
237c034141
8
types/seamless-immutable/index.d.ts
vendored
8
types/seamless-immutable/index.d.ts
vendored
@ -175,6 +175,14 @@ declare namespace SeamlessImmutable {
|
||||
function ImmutableError(message: string): Error;
|
||||
|
||||
function replace<T, S>(obj: Immutable<T>, valueObj: S, options?: ReplaceConfig): Immutable<S>;
|
||||
|
||||
function asMutable<T>(obj: T[] | ImmutableArray<T>, opts?: AsMutableOptions<false>): T[];
|
||||
function asMutable<T>(obj: T[] | ImmutableArray<T>, opts: AsMutableOptions<true>): T[];
|
||||
function asMutable<T>(obj: T[] | ImmutableArray<T>, opts: AsMutableOptions): T[] | Array<Immutable<T>>;
|
||||
|
||||
function asMutable<T>(obj: T | ImmutableObject<T>, opts?: AsMutableOptions<false>): { [K in keyof T]: Immutable<T[K]> };
|
||||
function asMutable<T>(obj: T | ImmutableObject<T>, opts: AsMutableOptions<true>): T;
|
||||
function asMutable<T>(obj: T | ImmutableObject<T>, opts: AsMutableOptions): T | { [K in keyof T]: Immutable<T[K]> };
|
||||
}
|
||||
|
||||
declare function SeamlessImmutable<T>(obj: T, options?: SeamlessImmutable.Options): SeamlessImmutable.Immutable<T>;
|
||||
|
||||
@ -86,8 +86,22 @@ interface NonDeepMutableExtendedUser {
|
||||
firstName: 'Angry',
|
||||
lastName: 'Monkey'
|
||||
});
|
||||
const users: Immutable.Immutable<string[]> = Immutable.from(['Angry']);
|
||||
|
||||
const replacedUser01 = Immutable.replace(user1, { firstName: 'Super', lastName: 'Monkey' });
|
||||
const replacedUser02 = Immutable.replace(user1, { firstName: 'Super', lastName: 'Monkey' }, { deep: true });
|
||||
|
||||
// $ExpectError
|
||||
user1.firstName = 'Untouchable';
|
||||
// asMutable on object
|
||||
const mutableObject = Immutable.asMutable(user1);
|
||||
mutableObject.firstName = 'Sedated';
|
||||
|
||||
// $ExpectError
|
||||
users.push('Super');
|
||||
// asMutable on array
|
||||
const mutableArray = Immutable.asMutable(users);
|
||||
mutableArray.push('Super');
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
Loading…
Reference in New Issue
Block a user