say
type incorrectly inferred as never
when using SlackEventMiddlewareArgs<'pin_added'>
#1472
Closed
4 of 10 tasks
Labels
bug
M-T: confirmed bug report. Issues are confirmed when the reproduction steps are documented
TypeScript-specific
Milestone
Description
The
SlackEventMiddlewareArgs
type contains asay
property that is set to typeSayFn
if the event contains achannel
property or aitem.channel
property. ThePinAddedEvent
type does have anitem.channel
property, however theWhenEventHasChannelContext
returnsnever
nonetheless.For example, the following code causes the TS error
but while running the code, you can clearly see that
say
correctly exists as afunction
:I noticed that the
PinAddedEvent.item
property is aRecord<string, unknown>
, so it may be that theWhenEventHasChannelContext
type function always returnsnever
due to theunknown
, but I'm not entirely clear on how that field populates. TheReactionAddedEvent
also has this problem, likely because itsitem
property is a union type ofReactionMessageItem | ReactionFileItem | ReactionFileCommentItem
and onlyReactionMessageItem
has achannel
field.As a positive case, using
SlackEventMiddlewareArgs<'message'>
works correctly and TS inferssay
to be aSayFn
.What type of issue is this? (place an
x
in one of the[ ]
)Requirements (place an
x
in each of the[ ]
)Bug Report
Filling out the following details about bugs will help us solve your issue sooner.
Reproducible in:
package version: 3.11.x
node version: 14.x
OS version(s): macOS Big Sur 11.6.6
Steps to reproduce:
app.event('pin_added', handlePinAdded);
say
property on the event.say('some message);'
inside the event handler.Expected result:
TS correctly infers the type of
say
to beSayFn
and transpiles without errors.Actual result:
TS incorrectly infers the type of
say
to benever
.Attachments:
The text was updated successfully, but these errors were encountered: