slackapi / node-slack-sdk

Slack Developer Kit for Node.js

Home Page:https://slack.dev/node-slack-sdk

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Update @slack/bolt to use slack/web-api v7 for compatibility

mister-good-deal opened this issue · comments

After updating @slack/web-api from v6 to v7, some imported type in TS were not sync anymore between @slack/bolt module and @slack/web-api module.

Example :

import type { WebClient } from "@slack/web-api";

must become

import type { WebClient } from "@slack/bolt/node_modules/@slack/web-api";

because the last version of @slack/bolt is using @slack/web-api v6 so the app failed to build.

Error was the following:

src/listeners/messages/bot-message.ts:43:79 - error TS2345: Argument of type 'import("/home/rom1/Projects/ai-project-team/slack/node_modules/@slack/bolt/node_modules/@slack/web-api/dist/WebClient").WebClient' is not assignable to parameter of type 'import("/home/rom1/Projects/ai-project-team/slack/node_modules/@slack/web-api/dist/WebClient").WebClient'.
  Property 'functions' is missing in type 'import("/home/rom1/Projects/ai-project-team/slack/node_modules/@slack/bolt/node_modules/@slack/web-api/dist/WebClient").WebClient' but required in type 'import("/home/rom1/Projects/ai-project-team/slack/node_modules/@slack/web-api/dist/WebClient").WebClient'.

43         if (!threadId) updateChannelPurposeWithThreadId(purpose, thread!.id!, client, genericMessage.channel);
                                                                                 ~~~~~~

  node_modules/@slack/web-api/dist/methods.d.ts:1008:14
    1008     readonly functions: {
                      ~~~~~~~~~
    'functions' is declared here.

In node_modules/@slack/bolt/dist/types/middleware.d.ts, WebClient is defined as import { WebClient } from '@slack/web-api';

Yes, in bolt we intentionally are keeping web-api to v6 within the bolt v3 line as web-api v7 is a breaking change. Updating web-api within bolt to v7 will necessitate a new major release of bolt. We are planning on doing this, but it will take a bit more time as there are other packages that bolt relies on (like @slack/socket-mode) that will also include breaking changes (though I am working on that as well; see #1732).

Ultimately your specific error here is dependent on how you import and use the types from web-api vs. bolt.

If you want to use BOTH bolt v3.x (with bundled web-api v6) AND web-api v7 at the same time, it will take delicate care, knowing that the two major versions of web-api are incompatible and which client is used in which situation.

Going to close this as eventually this will land in bolt (plus this is not the bolt repo).