bolt-js icon indicating copy to clipboard operation
bolt-js copied to clipboard

error TS2308: Module './types' has already exported a member named 'X'

Open pascal-sidlee opened this issue 2 years ago • 8 comments

@slack/bolt version

3.21.1

Your App and Receiver Configuration

const app = new App({ token: process.env.SLACK_BOT_TOKEN, socketMode: true, appToken: process.env.SLACK_APP_TOKEN, logger: logger, });

Node.js runtime version

18.17.0 64-bit

Steps to reproduce:

(Share the commands to run, source code, and project settings)

  1. npm install
  2. npm run start

Expected result:

Get all packages without any issues et build the app

Actual result:

Got 105 errors, like these:

node_modules/@slack/bolt/dist/index.d.ts:18:1 - error TS2308: Module './types' has already exported a member named 'WorkflowStepDeletedEvent'. Consider explicitly re-exporting to resolve the ambiguity.

18 export * from '@slack/types';
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@slack/bolt/dist/index.d.ts:18:1 - error TS2308: Module './types' has already exported a member named 'WorkflowStepExecuteEvent'. Consider explicitly re-exporting to resolve the ambiguity.

18 export * from '@slack/types';
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@slack/bolt/dist/index.d.ts:18:1 - error TS2308: Module './types' has already exported a member named 'WorkflowUnpublishedEvent'. Consider explicitly re-exporting to resolve the ambiguity.

18 export * from '@slack/types';

Requirements

pascal-sidlee avatar Sep 04 '24 12:09 pascal-sidlee

Weird issue, I tried to come back to the last successful version 3.18.0, and same issue now since the 29th august. No versions works now, event the old ones.

No packages were upgraded during this time.

pascal-sidlee avatar Sep 05 '24 13:09 pascal-sidlee

If we are using typescript, the issue comes from the file @slack/bolt/types/dist/index.d.ts, line 18. If I specify only types I need and they are not duplicate, the site is compiling successfully.

image

pascal-sidlee avatar Sep 05 '24 14:09 pascal-sidlee

Indeed there is a problem here. As per #2234 , this can be easily reproduced by:

git clone https://github.com/slackapi/bolt-js.git
cd bolt-js/examples/getting-started-typescript
npm i
npm run build

I believe it is due to the change I made where I took the event payloads that were a part of bolt-js and exposed them in the @slack/types repo (see abbe82c). Since bolt-js uses a floating version specifier for @slack/types, existing bolt apps would pull in this new types package, which includes the event payloads, but have the existing bolt-js repo also include the event payloads, leading to this error.

Possibly all that is needed is a new release of bolt-js. I am investigating. I will also add an integration test w/ the typescript example within this repo to ensure no regressions.

Sorry for the trouble 😢

filmaj avatar Sep 05 '24 14:09 filmaj

I am able to avoid this problem with the latest main commit, at least in the packaged examples/getting-started-typescript app, by npm linking @slack/bolt to it. This tells me the latest main does not have this problem. This makes sense to me as the latest main of bolt-js simply re-exports the @slack/types interfaces, so only one source (types) is exporting the types causing this issue.

I will create a PR to update this sample and add a basic integration test between this sample and the main repo as part of GitHub Action CI to help prevent regressions like this in the future. Once this is merged, I can then cut a new release of bolt-js which should fix the issue.

I will also implement a similar integration test between the various @slack/* modules that bolt-js relies on over in the https://github.com/slackapi/node-slack-sdk project. That kind of test would have at least caught this problem when I went to make the change in the types package last week.

I'll update this issue once a new version of bolt-js is live.

filmaj avatar Sep 05 '24 15:09 filmaj

bolt v3.21.2 is live on npm. Can someone see if this fixes the issue for them? @pascal-sidlee @yoychen

filmaj avatar Sep 05 '24 15:09 filmaj

Excellent, that fixed my issue, thanks!

pascal-sidlee avatar Sep 05 '24 17:09 pascal-sidlee

Great, thanks for confirming! Closing now, but feel free to re-open or open a new one if anything else arises.

filmaj avatar Sep 05 '24 17:09 filmaj

bolt v3.21.2 is live on npm. Can someone see if this fixes the issue for them? @pascal-sidlee @yoychen

It works, thanks!!! 🥳

yoychen avatar Sep 06 '24 02:09 yoychen