@@ -95,31 +95,43 @@ declare type Behave<T extends Pulse> = ({
9595 peak : SuccessPeak & { pulse : T }
9696} ) => Peak
9797
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 > >
100104}
101105
102106//===========//
103107// Operation //
104108//===========//
109+ // Based on: https://github.com/microsoft/TypeScript/pull/47109
105110declare 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 >
109118}
110119
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 >
114123}
115124
116125//======//
117126// Fire //
118127//======//
128+ // declare type Fire = {
129+ // red: Pulse | null
130+ // green: Pulse | null
131+ // blue: Pulse | null
132+ // }
119133declare type Fire = {
120- red : Pulse | null
121- green : Pulse | null
122- blue : Pulse | null
134+ [ key in PulseColour ] : Pulse | null
123135}
124136
125137//=======//
0 commit comments