Node-slack-sdk: SlackEventAdapter does not have type 'on'

Created on 28 Jan 2020  路  6Comments  路  Source: slackapi/node-slack-sdk

Description

I'm attempting to switch to using @slack/events-api with TypeScript and seem to be running into an error that is stating Property 'on' does not exist on type 'SlackEventAdapter' when trying to set up the event handling.

What type of issue is this? (place an x in one of the [ ])

  • [x] bug
  • [ ] enhancement (feature request)
  • [ ] question
  • [x] documentation related
  • [ ] testing related
  • [ ] discussion

Requirements (place an x in each of the [ ])

  • [x] I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • [x] I've read and agree to the Code of Conduct.
  • [x] I've searched for any related issues and avoided creating a duplicate issue.

Bug Report

Filling out the following details about bugs will help us solve your issue sooner.

Packages:

Select all that apply:

  • [ ] @slack/web-api
  • [x] @slack/events-api
  • [ ] @slack/interactive-messages
  • [ ] @slack/rtm-api
  • [ ] @slack/webhooks
  • [ ] I don't know

Reproducible in:

package version: 2.3.1

node version: 12.13.1

OS version(s): Mac OSX

Steps to reproduce:

  1. import createEventAdapter using import { createEventAdapter } from '@slack/events-api'
  2. set up the createEventAdapter using const adapter = createEventAdapter(signingSecret)
  3. type adapter.on('link_shared', (event) => console.log(event)) and see the typescript error

Expected result: There to be no typescript errors

Actual result: Typescript error listed above.

Attachments:

Screen Shot 2020-01-28 at 1 10 00 PM

events-api

Most helpful comment

@net8floz you are right. I believe https://github.com/slackapi/node-slack-sdk/pull/958 fixed this problem. I'm going to close this issue and aim to get a release out today/tomorrow with the fix.

All 6 comments

Here is my workaround atm:

const slackEvents: SlackEventAdapter & EventEmitter = createEventAdapter(
  slackSigningSecret
) as any;

This is due to a change in the types for Node 13 (see here). Installing @types/[email protected] in my project fixes this for me.

would love a fix for this. I see there's a PR in another issue that fixes this. The issue is that event emitter and http have no default import. The PR looks like it just needs a reviewer to approve it. Thanks for the work on this repo.

@net8floz you are right. I believe https://github.com/slackapi/node-slack-sdk/pull/958 fixed this problem. I'm going to close this issue and aim to get a release out today/tomorrow with the fix.

I'm on node 14 and seeing this. Is there a fix planned before Node 14 becomes current, October 20? Or perhaps this is unique to me?

I'm also facing this problem and installed the @types/[email protected] package as a dev dependency to get rid of the error.
Is there any plan to fix the problem for the latest node type definitions??

Was this page helpful?
0 / 5 - 0 ratings

Related issues

amkoehler picture amkoehler  路  13Comments

CoreyCole picture CoreyCole  路  12Comments

freder picture freder  路  12Comments

dcsan picture dcsan  路  12Comments

lrettig picture lrettig  路  21Comments