@@ -95,31 +95,43 @@ declare type Behave<T extends Pulse> = ({
95
95
peak : SuccessPeak & { pulse : T }
96
96
} ) => Peak
97
97
98
- declare type BehaviourMap = {
99
- [ key in PulseType ] : Behave < Extract < Pulse , { type : key } > >
98
+ declare type PulseMap < key extends PulseType = PulseType > = {
99
+ [ P in key ] : { type : P } & Omit < Extract < Pulse , { type : P } > , "type" >
100
+ } [ key ]
101
+
102
+ declare type BehaviourMap < key extends PulseType = PulseType > = {
103
+ [ P in key ] : Behave < PulseMap < P > >
100
104
}
101
105
102
106
//===========//
103
107
// Operation //
104
108
//===========//
109
+ // Based on: https://github.com/microsoft/TypeScript/pull/47109
105
110
declare type Operation = ReportOperation | InstructionOperation
106
- declare type Operate < T extends Operation > = ( nogan : Nogan , operation : T ) => Operation [ ]
107
- declare type OperationMap = {
108
- [ key in OperationType ] : Operate < Extract < Operation , { type : key } > >
111
+ declare type OperationMap < key extends OperationType = OperationType > = {
112
+ [ P in key ] : { type : P } & Omit < Extract < Operation , { type : P } > , "type" >
113
+ } [ key ]
114
+
115
+ declare type Operate < key extends OperationType > = ( nogan : Nogan , operation : OperationMap < key > ) => Operation [ ]
116
+ declare type OperateMap < key extends OperationType = OperationType > = {
117
+ [ P in key ] : Operate < P >
109
118
}
110
119
111
- declare type TunnelFunction < T extends Operation > = ( operation : T ) => void
112
- declare type TunnelMap = {
113
- [ key in OperationType ] : TunnelFunction < Extract < Operation , { type : key } > >
120
+ declare type TunnelFunction < key extends OperationType = OperationType > = ( operation : OperationMap < key > ) => void
121
+ declare type TunnelMap < key extends OperationType = OperationType > = {
122
+ [ P in key ] : TunnelFunction < P >
114
123
}
115
124
116
125
//======//
117
126
// Fire //
118
127
//======//
128
+ // declare type Fire = {
129
+ // red: Pulse | null
130
+ // green: Pulse | null
131
+ // blue: Pulse | null
132
+ // }
119
133
declare type Fire = {
120
- red : Pulse | null
121
- green : Pulse | null
122
- blue : Pulse | null
134
+ [ key in PulseColour ] : Pulse | null
123
135
}
124
136
125
137
//=======//
0 commit comments