From b489356bba0e92552a5eebbd6ec3cd652de16224 Mon Sep 17 00:00:00 2001 From: Kwok Chi Leong Date: Fri, 16 Aug 2019 05:27:22 +0800 Subject: [PATCH] [@types/map-to-obj] New type definition (#37638) * [@types/map-to-obj] New type definition * [@types/map-to-obj] Fixed typo --- types/map-to-obj/index.d.ts | 13 +++++++++++++ types/map-to-obj/map-to-obj-tests.ts | 18 ++++++++++++++++++ types/map-to-obj/tsconfig.json | 25 +++++++++++++++++++++++++ types/map-to-obj/tslint.json | 1 + 4 files changed, 57 insertions(+) create mode 100644 types/map-to-obj/index.d.ts create mode 100644 types/map-to-obj/map-to-obj-tests.ts create mode 100644 types/map-to-obj/tsconfig.json create mode 100644 types/map-to-obj/tslint.json diff --git a/types/map-to-obj/index.d.ts b/types/map-to-obj/index.d.ts new file mode 100644 index 0000000000..60a3433fdb --- /dev/null +++ b/types/map-to-obj/index.d.ts @@ -0,0 +1,13 @@ +// Type definitions for map-to-obj 0.2 +// Project: https://github.com/egoist/map-to-obj#readme +// Definitions by: Jason Kwok +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.9 + +/** + * Convert a `Map` instance into a plain `object`. + * @param map The target to be converted + */ +declare function MapToObj(map: Map): Record; + +export = MapToObj; diff --git a/types/map-to-obj/map-to-obj-tests.ts b/types/map-to-obj/map-to-obj-tests.ts new file mode 100644 index 0000000000..0f6274d8ae --- /dev/null +++ b/types/map-to-obj/map-to-obj-tests.ts @@ -0,0 +1,18 @@ +'use strict'; + +import MapToObj from 'map-to-obj'; + +// $ExpectType Record +MapToObj(new Map()); + +// $ExpectType Record +MapToObj(new Map([['hello', 'world']])); + +// $ExpectType Record +MapToObj(new Map([[0, 1]])); + +// $ExpectType Record +MapToObj(new Map([[Symbol('hello'), Symbol('world')]])); + +// $ExpectError +MapToObj(new Map([[{}, {}]])); diff --git a/types/map-to-obj/tsconfig.json b/types/map-to-obj/tsconfig.json new file mode 100644 index 0000000000..adae307be7 --- /dev/null +++ b/types/map-to-obj/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "allowSyntheticDefaultImports": true, + "esModuleInterop": true + }, + "files": [ + "index.d.ts", + "map-to-obj-tests.ts" + ] +} diff --git a/types/map-to-obj/tslint.json b/types/map-to-obj/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/map-to-obj/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }