Skip to content

Commit

Permalink
Merge pull request #10921 from gmoothart/readonly-collections
Browse files Browse the repository at this point in the history
Add readonly typings for Set and Map
  • Loading branch information
mhegazy authored Sep 15, 2016
2 parents 10b3d73 + a9d4b30 commit 9d8d2b6
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/lib/es2015.collection.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
interface Map<K, V> {
clear(): void;
delete(key: K): boolean;
forEach(callbackfn: (value: V, index: K, map: Map<K, V>) => void, thisArg?: any): void;
forEach(callbackfn: (value: V, key: K, map: Map<K, V>) => void, thisArg?: any): void;
get(key: K): V | undefined;
has(key: K): boolean;
set(key: K, value?: V): this;
Expand All @@ -15,6 +15,13 @@ interface MapConstructor {
}
declare var Map: MapConstructor;

interface ReadonlyMap<K, V> {
forEach(callbackfn: (value: V, key: K, map: ReadonlyMap<K, V>) => void, thisArg?: any): void;
get(key: K): V|undefined;
has(key: K): boolean;
readonly size: number;
}

interface WeakMap<K, V> {
delete(key: K): boolean;
get(key: K): V | undefined;
Expand All @@ -33,7 +40,7 @@ interface Set<T> {
add(value: T): this;
clear(): void;
delete(value: T): boolean;
forEach(callbackfn: (value: T, index: T, set: Set<T>) => void, thisArg?: any): void;
forEach(callbackfn: (value: T, value2: T, set: Set<T>) => void, thisArg?: any): void;
has(value: T): boolean;
readonly size: number;
}
Expand All @@ -45,6 +52,12 @@ interface SetConstructor {
}
declare var Set: SetConstructor;

interface ReadonlySet<T> {
forEach(callbackfn: (value: T, value2: T, set: ReadonlySet<T>) => void, thisArg?: any): void;
has(value: T): boolean;
readonly size: number;
}

interface WeakSet<T> {
add(value: T): this;
delete(value: T): boolean;
Expand Down

0 comments on commit 9d8d2b6

Please sign in to comment.