Merge pull request #14334 from pine/feature/es6-weak-map

Add type definitions for es6-weak-map
This commit is contained in:
Arthur Ozga
2017-02-09 16:43:24 -08:00
committed by GitHub
4 changed files with 63 additions and 0 deletions
+18
View File
@@ -0,0 +1,18 @@
import WeakMap = require('es6-weak-map');
new WeakMap<{}, string>();
var tuples: [number, string][] = [ [0, 'foo'], [1, 'bar'] ];
new WeakMap<number, string>(tuples);
var map = new WeakMap<{}, string>();
var obj = {};
map.set(obj, 'foo');
map.get(obj);
map.has(obj);
map.delete(obj);
map.get(obj);
map.has(obj);
map.set(obj, 'bar');
map.has(obj);
+21
View File
@@ -0,0 +1,21 @@
// Type definitions for es6-weak-map 1.2
// Project: https://github.com/medikoo/es6-weak-map
// Definitions by: Pine Mizune <https://github.com/pine>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export = WeakMap;
export as namespace WeakMap;
interface Iterable<T> {
[Symbol.iterator](): Iterator<T>;
}
declare class WeakMap<K, V> {
constructor();
constructor(iterable: Iterable<[K, V]>);
delete(key: K): boolean;
get(key: K): V;
has(key: K): boolean;
set(key: K, value?: V): WeakMap<K, V>;
}
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"es6-weak-map-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "../tslint.json" }