File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed
libs/core/src/lib/declarations Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change 1+ /**
2+ * Get the known keys (i.e. no index signature) of T.
3+ *
4+ * @example
5+ ```typescript
6+ interface Options {
7+ key: string;
8+ title: string;
9+ [dataProperty: string]: string | number;
10+ }
11+
12+ type KnownKeysOfOptions = KnownKeys<Options>; // 'key' | 'title';
13+ // (vs. type KeysOfOptions = keyof Options // string | number;)
14+ ```
15+
16+ * Taken from https://stackoverflow.com/questions/51465182/typescript-remove-index-signature-using-mapped-types
17+ */
18+ export type KnownKeys < T > = { [ K in keyof T ] : string extends K ? never : number extends K ? never : K } extends {
19+ [ _ in keyof T ] : infer U
20+ }
21+ ? U
22+ : never ;
Original file line number Diff line number Diff line change 11// Copyright (c) Microsoft Corporation. All rights reserved.
22// Licensed under the MIT License.
33
4+ export * from './known-keys' ;
45export * from './omit' ;
56export * from './StringMap' ;
You can’t perform that action at this time.
0 commit comments