File tree Expand file tree Collapse file tree 2 files changed +15
-12
lines changed
Expand file tree Collapse file tree 2 files changed +15
-12
lines changed Original file line number Diff line number Diff line change @@ -36,21 +36,14 @@ export type GraphType = 'single_metric' | 'predefined_graph';
3636
3737export type Aggregation = 'off' | 'sum' | 'average' | 'minimum' | 'maximum' ;
3838
39- export type RequestSpecStringKeys = 'host_name' | 'site' | 'service' | 'graph' | 'graph_type' | 'aggregation' ;
39+ export type PickByValue < T , V > = Pick < T , { [ K in keyof T ] : T [ K ] extends V ? K : never } [ keyof T ] > ;
4040
41- export type RequestSpecNegatableOptionKeys = 'host_name_regex' | 'service_regex' | 'host_in_group' | 'service_in_group' ;
41+ export type RequestSpecStringKeys = keyof PickByValue < RequestSpec , string | undefined > ;
42+
43+ export type RequestSpecNegatableOptionKeys = keyof PickByValue < RequestSpec , NegatableOption | undefined > ;
4244
4345export const defaultRequestSpec : Partial < RequestSpec > = {
4446 aggregation : 'off' ,
4547 graph_type : 'predefined_graph' ,
4648} ;
47- export type FilterEditorKeys =
48- | 'site'
49- | 'host_name'
50- | 'host_name_regex'
51- | 'host_in_group'
52- | 'host_labels'
53- | 'host_tags'
54- | 'service'
55- | 'service_regex'
56- | 'service_in_group' ;
49+ export type FilterEditorKeys = Exclude < keyof RequestSpec , 'graph_type' | 'aggregation' | 'graph' > ;
Original file line number Diff line number Diff line change 1+ import { PickByValue } from '../../src/RequestSpec' ;
2+
3+ type Test = PickByValue < { foo : string ; bar : number } , string > ;
4+ const value : Test = { foo : '' } ;
5+
6+ describe ( 'we have no unit tests yet' , ( ) => {
7+ it ( 'but want just make sure PickByValue works as expected' , ( ) => {
8+ expect ( 1 ) . toStrictEqual ( 1 ) ;
9+ } ) ;
10+ } ) ;
You can’t perform that action at this time.
0 commit comments