UNPKG

2.19 kBTypeScriptView Raw
1/*---------------------------------------------------------------------------------------------
2 * Copyright (c) Microsoft Corporation. All rights reserved.
3 * Licensed under the MIT License. See License.txt in the project root for license information.
4 *--------------------------------------------------------------------------------------------*/
5
6// Defined a subset of ES6 built ins that run in IE11
7// CHECK WITH http://kangax.github.io/compat-table/es6/#ie11
8
9interface Map<K, V> {
10 clear(): void;
11 delete(key: K): boolean;
12 forEach(callbackfn: (value: V, index: K, map: Map<K, V>) => void, thisArg?: any): void;
13 get(key: K): V | undefined;
14 has(key: K): boolean;
15 set(key: K, value?: V): Map<K, V>;
16 readonly size: number;
17
18 // not supported on IE11:
19 // entries(): IterableIterator<[K, V]>;
20 // keys(): IterableIterator<K>;
21 // values(): IterableIterator<V>;
22 // [Symbol.iterator]():IterableIterator<[K,V]>;
23 // [Symbol.toStringTag]: string;
24}
25
26interface MapConstructor {
27 new <K, V>(): Map<K, V>;
28
29 // not supported on IE11:
30 // new <K, V>(iterable: Iterable<[K, V]>): Map<K, V>;
31}
32declare var Map: MapConstructor;
33
34
35interface Set<T> {
36 add(value: T): Set<T>;
37 clear(): void;
38 delete(value: T): boolean;
39 forEach(callbackfn: (value: T, index: T, set: Set<T>) => void, thisArg?: any): void;
40 has(value: T): boolean;
41 readonly size: number;
42
43 // not supported on IE11:
44 // entries(): IterableIterator<[T, T]>;
45 // keys(): IterableIterator<T>;
46 // values(): IterableIterator<T>;
47 // [Symbol.iterator]():IterableIterator<T>;
48 // [Symbol.toStringTag]: string;
49}
50
51interface SetConstructor {
52 new <T>(): Set<T>;
53
54 // not supported on IE11:
55 // new <T>(iterable: Iterable<T>): Set<T>;
56}
57declare var Set: SetConstructor;
58
59
60interface WeakMap<K extends object, V> {
61 delete(key: K): boolean;
62 get(key: K): V | undefined;
63 has(key: K): boolean;
64 // IE11 doesn't return this
65 // set(key: K, value?: V): this;
66 set(key: K, value?: V): undefined;
67}
68
69interface WeakMapConstructor {
70 new(): WeakMap<any, any>;
71 new <K extends object, V>(): WeakMap<K, V>;
72 // new <K, V>(entries?: [K, V][]): WeakMap<K, V>;
73 readonly prototype: WeakMap<object, any>;
74}
75declare var WeakMap: WeakMapConstructor;