mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-04-05 05:04:26 +00:00
[@types/map-to-obj] New type definition (#37638)
* [@types/map-to-obj] New type definition * [@types/map-to-obj] Fixed typo
This commit is contained in:
committed by
Pranav Senthilnathan
parent
c38b215bfb
commit
b489356bba
13
types/map-to-obj/index.d.ts
vendored
Normal file
13
types/map-to-obj/index.d.ts
vendored
Normal file
@@ -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 <https://github.com/JasonHK>
|
||||
// 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<K extends string | number | symbol, V>(map: Map<K, V>): Record<K, V>;
|
||||
|
||||
export = MapToObj;
|
||||
18
types/map-to-obj/map-to-obj-tests.ts
Normal file
18
types/map-to-obj/map-to-obj-tests.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
'use strict';
|
||||
|
||||
import MapToObj from 'map-to-obj';
|
||||
|
||||
// $ExpectType Record<any, any>
|
||||
MapToObj(new Map());
|
||||
|
||||
// $ExpectType Record<string, string>
|
||||
MapToObj(new Map([['hello', 'world']]));
|
||||
|
||||
// $ExpectType Record<number, number>
|
||||
MapToObj(new Map([[0, 1]]));
|
||||
|
||||
// $ExpectType Record<symbol, symbol>
|
||||
MapToObj(new Map([[Symbol('hello'), Symbol('world')]]));
|
||||
|
||||
// $ExpectError
|
||||
MapToObj(new Map([[{}, {}]]));
|
||||
25
types/map-to-obj/tsconfig.json
Normal file
25
types/map-to-obj/tsconfig.json
Normal file
@@ -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"
|
||||
]
|
||||
}
|
||||
1
types/map-to-obj/tslint.json
Normal file
1
types/map-to-obj/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user