mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-22 03:37:53 +08:00
Using mapped types from Typescript 2.1.
The type returned is as we might expect from keyMirror. In the test case
of:
keyMirror({key1: null, key2: null})
We get the type:
{ key1: 'key1'; key2: 'key2'; }
Instead of:
{ [key: string]: string; }
Which is what we got before.
Both check lines in the test file fail with the previous type
definition.
9 lines
334 B
TypeScript
9 lines
334 B
TypeScript
// Type definitions for keymirror 0.1.1
|
|
// Project: https://github.com/STRML/keyMirror
|
|
// Definitions by: Johannes Fahrenkrug <https://github.com/jfahrenkrug>
|
|
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
// TypeScript Version: 2.1
|
|
|
|
declare function KeyMirror<T>(obj: T): {[K in keyof T]: K};
|
|
export = KeyMirror;
|