Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export Reaction Interfaces #776

Merged
merged 2 commits into from
Feb 4, 2021
Merged

Export Reaction Interfaces #776

merged 2 commits into from
Feb 4, 2021

Conversation

khrj
Copy link
Contributor

@khrj khrj commented Feb 1, 2021

Summary

Accessing the "channel" type on event.item requires a type cast / type guard since multiple types exist. However, the types are not exported so this isn't possible.

Now:

app.event('reaction_added', async ({ event }) => {
        console.log(event.item.channel)
})

results in

Property 'channel' does not exist on type 'ReactionMessageItem | ReactionFileItem | ReactionFileCommentItem'.
  Property 'channel' does not exist on type 'ReactionFileItem'

After patch:

(preferred)

import { ReactionMessageItem } from '@slack/bolt' 
app.event('reaction_added', async ({ event }) => {
    if (reactionIsMessageItem(event.item)) {
        console.log(event.item.channel)
    }
})

function reactionIsMessageItem (reaction: ReactionMessageItem | ReactionFileItem | ReactionFileCommentItem): reaction is ReactionMessageItem {
    return !! (reaction as ReactionMessageItem).channel
}

or

import { ReactionMessageItem } from '@slack/bolt' 
app.event('reaction_added', async ({ event }) => {
    console.log(event.item.channel as ReactionMessageItem)
})

Requirements


Fixes #765

@gitwave gitwave bot added the untriaged label Feb 1, 2021
@CLAassistant
Copy link

CLAassistant commented Feb 1, 2021

CLA assistant check
All committers have signed the CLA.

@codecov
Copy link

codecov bot commented Feb 1, 2021

Codecov Report

Merging #776 (5d36e6d) into main (adff9a3) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #776   +/-   ##
=======================================
  Coverage   65.24%   65.24%           
=======================================
  Files          11       11           
  Lines        1082     1082           
  Branches      320      320           
=======================================
  Hits          706      706           
  Misses        317      317           
  Partials       59       59           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update adff9a3...5d36e6d. Read the comment docs.

@seratch
Copy link
Member

seratch commented Feb 1, 2021

Thanks for taking the time to make this PR! It seems that this pull request will fix #765

@seratch seratch added bug M-T: confirmed bug report. Issues are confirmed when the reproduction steps are documented TypeScript-specific and removed untriaged labels Feb 1, 2021
@khrj
Copy link
Contributor Author

khrj commented Feb 1, 2021

I've added a fixes note in the description

@stevengill stevengill merged commit 2dc7f65 into slackapi:main Feb 4, 2021
@stevengill
Copy link
Member

Thanks for sending this PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug M-T: confirmed bug report. Issues are confirmed when the reproduction steps are documented TypeScript-specific
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ReactionAddedEvent uses non-exported sub interfaces.
4 participants