Skip to content

Commit 2970b4e

Browse files
fix addSteps parameter type on concatSteps
it should fully check it's a proper ConsList
1 parent 7794053 commit 2970b4e

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/object_chain.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ export type ObjectChain<Input extends ChainTagged,
4646
Steps extends cons.NRConsList<UPObjectStepSpec>,
4747
// this param is only here so that a chain value's IntelliSense
4848
// shows the chain's return type
49-
_Return = ObjectChainStepsReturn<Steps,Input>> = {
49+
_Return = ObjectChainStepsReturn<Steps, Input>> = {
5050

5151
readonly tag: ChainTag<Input>
5252
readonly tagStr: Input['_tag']
5353

54-
readonly steps: ObjectChainSteps<Steps, Input> extends Steps
54+
readonly steps: Steps extends ObjectChainSteps<Steps, Input>
5555
? Steps
5656
: ObjectChainSteps<Steps, Input>
5757

@@ -207,18 +207,19 @@ export function makePureStep
207207
export function concatSteps
208208
<Input extends ChainTagged,
209209
const ChainSteps extends cons.NRConsList<UPObjectStepSpec>,
210-
const NewSteps extends cons.NRConsList<UPObjectStepSpec>>
210+
const AddSteps extends cons.NRConsList<UPObjectStepSpec>>
211211
(chain: ObjectChain<Input, ChainSteps>,
212-
addSteps: NewSteps) {
213-
214-
const newSteps =
212+
addSteps: AddSteps extends cons.ConsList<UPObjectStepSpec, AddSteps>
213+
? AddSteps
214+
: cons.ConsList<UPObjectStepSpec, AddSteps>) {
215+
216+
const newSteps =
215217
// deno-lint-ignore no-explicit-any
216218
cons.concat<UPObjectStepSpec>()(chain.steps as any, addSteps as any)
217-
219+
218220
// deno-lint-ignore no-explicit-any
219221
return objectChain<Input>()(chain.tag, newSteps as any) as
220-
ObjectChain<Input, cons.Concat<UPObjectStepSpec, ChainSteps, NewSteps>>
221-
222+
ObjectChain<Input, cons.Concat<UPObjectStepSpec, ChainSteps, AddSteps>>
222223
}
223224

224225
////////////////////////////////// recursion support ////////////////////

0 commit comments

Comments
 (0)