Skip to content

Commit

Permalink
fix: nested DeepImmutable and Immutable types neutralization
Browse files Browse the repository at this point in the history
closes #65
  • Loading branch information
Mohammad Hasani authored and the-dr-lazy committed Jun 9, 2019
1 parent c6c1d30 commit d3f9a1a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ export type Immutable<T> = T extends Primitive
? ReadonlyArray<U>
: T extends Map<infer K, infer V>
? ReadonlyMap<K, V>
: T extends ReadonlyArray<any>
? T
: T extends ReadonlyMap<any, any>
? T
: Readonly<T>

export type DeepImmutable<T> = T extends Primitive
Expand All @@ -25,6 +29,10 @@ export type DeepImmutable<T> = T extends Primitive
? DeepImmutableArray<U>
: T extends Map<infer K, infer V>
? DeepImmutableMap<K, V>
: T extends ReadonlyArray<infer U>
? DeepImmutableArray<U>
: T extends ReadonlyMap<infer K, infer V>
? DeepImmutableMap<K, V>
: DeepImmutableObject<T>

export type Reducer<TState, TAction> = (
Expand Down

0 comments on commit d3f9a1a

Please sign in to comment.