Node-slack-sdk: How about to set false 'esModuleInterop' on tsconfig.json?

Created on 26 Sep 2019  路  4Comments  路  Source: slackapi/node-slack-sdk

Description

The "node slack sdk" uses "esModuleInterop" for all projects. It makes me fail to compile my own projects. Especially, "event-api" package imports "EventEmitter" from "events" module as default. In this case, projects which set "esModuleInterop" false get compile error like Module '"events"' has no default export..

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

  • [ ] bug
  • [ ] enhancement (feature request)
  • [ ] question
  • [ ] documentation related
  • [ ] testing related
  • [x] 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.

Packages:

Select all that apply:

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

All 4 comments

Hi @Ikanny, thanks for making us aware of this issue! This sounds like the same issue as in #759, except its in the @slack/events-api package instead of @slack/web-api.

My next steps here are to try and reproduce the issue as you described, but also make sure the other packages in this repo work correctly with esModuleInterop turned off. I hope to put these in the integration tests, as we did in #760, so that we don't regress on this in the future.

I was able to reproduce the failure in a scrap project. It only impacts @slack/events-api and @slack/interactive-messages.

Then I made a failing test in the integration tests. I'll open a draft PR for this, but if anyone else would like to pick that PR up and implement the fix, please feel free!

Hi @aoberoi, I opened a PR, please have a look. #923

@saeedseyfi your PR seems to fix one particular use case but does not prevent build failures with external projects where esModuleInterop is set to false.

As for me, when trying to set esModuleInterop to true, I get

node_modules/@slack/events-api/dist/adapter.d.ts:8:48 - error TS2507: Type 'typeof EventEmitter' is not a constructor function type.

8 export declare class SlackEventAdapter extends EventEmitter {
Was this page helpful?
0 / 5 - 0 ratings