Skip to content

Commit 4f039ad

Browse files
author
Ben Grynhaus
committed
Add IndexSignature mapped type
1 parent fb72bd9 commit 4f039ad

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* Gets the index signature of a type.
3+
*
4+
* @example
5+
```typescript
6+
interface Options {
7+
key: string;
8+
title: string;
9+
[dataProperty: string]: string | number;
10+
}
11+
12+
type IndexOfOptions = IndexSignature<Options>; // { [x: string]: string | number; [x: number]: string | number; }
13+
```
14+
*/
15+
export type IndexSignature<T> = Pick<T, keyof T>;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

4+
export * from './index-signature';
45
export * from './known-keys';
56
export * from './omit';
67
export * from './StringMap';

0 commit comments

Comments
 (0)