slackapi / node-slack-sdk

Slack Developer Kit for Node.js
https://slack.dev/node-slack-sdk
MIT License
3.26k stars 656 forks source link

Introduced in 7.3.0: "Only named exports may use 'export type'" #1840

Closed 742617000027 closed 3 weeks ago

742617000027 commented 3 weeks ago

Hi! 7.3.0 seems to have introducted an issue where a project using @slack/web-api does not compile any longer (no such issues up until and including 7.2.0):

> npx tsc

node_modules/@slack/web-api/dist/types/request/index.d.ts:1:1 - error TS1383: Only named exports may use 'export type'.

1 export type * from './workflows';
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@slack/web-api/dist/types/request/index.d.ts:2:1 - error TS1383: Only named exports may use 'export type'.

2 export type * from './views';
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@slack/web-api/dist/types/request/index.d.ts:3:1 - error TS1383: Only named exports may use 'export type'.

3 export type * from './users';
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@slack/web-api/dist/types/request/index.d.ts:4:1 - error TS1383: Only named exports may use 'export type'.

4 export type * from './tooling';
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@slack/web-api/dist/types/request/index.d.ts:5:1 - error TS1383: Only named exports may use 'export type'.

5 export type * from './search';
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@slack/web-api/dist/types/request/index.d.ts:6:1 - error TS1383: Only named exports may use 'export type'.

6 export type * from './usergroups';
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@slack/web-api/dist/types/request/index.d.ts:7:1 - error TS1383: Only named exports may use 'export type'.

7 export type * from './team';
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@slack/web-api/dist/types/request/index.d.ts:8:1 - error TS1383: Only named exports may use 'export type'.

8 export type * from './stars';
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@slack/web-api/dist/types/request/index.d.ts:9:1 - error TS1383: Only named exports may use 'export type'.

9 export type * from './rtm';
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@slack/web-api/dist/types/request/index.d.ts:10:1 - error TS1383: Only named exports may use 'export type'.

10 export type * from './reminders';
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@slack/web-api/dist/types/request/index.d.ts:11:1 - error TS1383: Only named exports may use 'export type'.

11 export type * from './reactions';
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@slack/web-api/dist/types/request/index.d.ts:12:1 - error TS1383: Only named exports may use 'export type'.

12 export type * from './pins';
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@slack/web-api/dist/types/request/index.d.ts:13:1 - error TS1383: Only named exports may use 'export type'.

13 export type * from './openid';
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@slack/web-api/dist/types/request/index.d.ts:14:1 - error TS1383: Only named exports may use 'export type'.

14 export type * from './oauth';
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@slack/web-api/dist/types/request/index.d.ts:15:1 - error TS1383: Only named exports may use 'export type'.

15 export type * from './migration';
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@slack/web-api/dist/types/request/index.d.ts:16:1 - error TS1383: Only named exports may use 'export type'.

16 export type * from './files';
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@slack/web-api/dist/types/request/index.d.ts:17:1 - error TS1383: Only named exports may use 'export type'.

17 export type * from './emoji';
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@slack/web-api/dist/types/request/index.d.ts:18:1 - error TS1383: Only named exports may use 'export type'.

18 export type * from './dnd';
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@slack/web-api/dist/types/request/index.d.ts:19:1 - error TS1383: Only named exports may use 'export type'.

19 export type * from './dialog';
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@slack/web-api/dist/types/request/index.d.ts:20:1 - error TS1383: Only named exports may use 'export type'.

20 export type * from './conversations';
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@slack/web-api/dist/types/request/index.d.ts:21:1 - error TS1383: Only named exports may use 'export type'.

21 export type * from './chat';
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@slack/web-api/dist/types/request/index.d.ts:22:1 - error TS1383: Only named exports may use 'export type'.

22 export type * from './canvas';
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@slack/web-api/dist/types/request/index.d.ts:23:1 - error TS1383: Only named exports may use 'export type'.

23 export type * from './calls';
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@slack/web-api/dist/types/request/index.d.ts:24:1 - error TS1383: Only named exports may use 'export type'.

24 export type * from './bots';
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@slack/web-api/dist/types/request/index.d.ts:25:1 - error TS1383: Only named exports may use 'export type'.

25 export type * from './bookmarks';
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@slack/web-api/dist/types/request/index.d.ts:26:1 - error TS1383: Only named exports may use 'export type'.

26 export type * from './auth';
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@slack/web-api/dist/types/request/index.d.ts:27:1 - error TS1383: Only named exports may use 'export type'.

27 export type * from './apps';
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@slack/web-api/dist/types/request/index.d.ts:28:1 - error TS1383: Only named exports may use 'export type'.

28 export type * from './api';
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@slack/web-api/dist/types/request/index.d.ts:29:1 - error TS1383: Only named exports may use 'export type'.

29 export type * from './admin/analytics';
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@slack/web-api/dist/types/request/index.d.ts:30:1 - error TS1383: Only named exports may use 'export type'.

30 export type * from './admin/apps';
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@slack/web-api/dist/types/request/index.d.ts:31:1 - error TS1383: Only named exports may use 'export type'.

31 export type * from './admin/auth';
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@slack/web-api/dist/types/request/index.d.ts:32:1 - error TS1383: Only named exports may use 'export type'.

32 export type * from './admin/barriers';
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@slack/web-api/dist/types/request/index.d.ts:33:1 - error TS1383: Only named exports may use 'export type'.

33 export type * from './admin/conversations';
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@slack/web-api/dist/types/request/index.d.ts:34:1 - error TS1383: Only named exports may use 'export type'.

34 export type * from './admin/emoji';
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@slack/web-api/dist/types/request/index.d.ts:35:1 - error TS1383: Only named exports may use 'export type'.

35 export type * from './admin/functions';
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@slack/web-api/dist/types/request/index.d.ts:36:1 - error TS1383: Only named exports may use 'export type'.

36 export type * from './functions';
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@slack/web-api/dist/types/request/index.d.ts:37:1 - error TS1383: Only named exports may use 'export type'.

37 export type * from './admin/inviteRequests';
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@slack/web-api/dist/types/request/index.d.ts:38:1 - error TS1383: Only named exports may use 'export type'.

38 export type * from './admin/roles';
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@slack/web-api/dist/types/request/index.d.ts:39:1 - error TS1383: Only named exports may use 'export type'.

39 export type * from './admin/teams';
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@slack/web-api/dist/types/request/index.d.ts:40:1 - error TS1383: Only named exports may use 'export type'.

40 export type * from './admin/usergroups';
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@slack/web-api/dist/types/request/index.d.ts:41:1 - error TS1383: Only named exports may use 'export type'.

41 export type * from './admin/users';
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@slack/web-api/dist/types/request/index.d.ts:42:1 - error TS1383: Only named exports may use 'export type'.

42 export type * from './admin/workflows';
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Found 42 errors in the same file, starting at: node_modules/@slack/web-api/dist/types/request/index.d.ts:1

Packages:

Select all that apply:

Reproducible in:

The Slack SDK version

"slack/web-api": "^7.3.0"

TypeScript version

"typescript": "^4.7"

Node.js runtime version

v18.19.0

OS info

ProductName: macOS ProductVersion: 14.5 BuildVersion: 23F79 Darwin Kernel Version 23.5.0: Wed May 1 20:16:51 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T8103

Steps to reproduce:

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

  1. Run npm i on the project
  2. Run npx tsc

Expected result:

No compile errors.

Actual result:

Compile errors as showcased above.

Requirements

For general questions/issues about Slack API platform or its server-side, could you submit questions at https://my.slack.com/help/requests/new instead. :bow:

Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.

seratch commented 3 weeks ago

Hi @742617000027, thanks for taking the time to report this!

@filmaj This pull request seems to be the cause of this issue: https://github.com/slackapi/node-slack-sdk/pull/1834 Can you take a look at this tomorrow? Perhaps, just reverting the relevant changes (or making valid changes instead) shoudl resolve it.

filmaj commented 3 weeks ago

I don't think this is a problem with this package; TypeScript 5.0 introduced the ability to import all types from a module. Since the new major version web-api 7.0, we moved to TypeScript 5+.

My suggestion would be to upgrade TypeScript in whatever project consumes this package. Is that possible for you @742617000027 ?

I could release a temporary fix, moving back to the old way, but it would not prevent other, similar such issues in the future. The real question here is: what range of TypeScript versions should this package guarantee compatibility with?

742617000027 commented 3 weeks ago

My suggestion would be to upgrade TypeScript in whatever project consumes this package. Is that possible for you @742617000027 ?

We'll evaluate it (it's not like it hasn't been on our agenda for ages 🙃), for now we'll just stick to 7.2.0 then.

The real question here is: what range of TypeScript versions should this package guarantee compatibility with?

Agreed, and I don't think there needs to be endless backward compatibility, but a hint in the release notes that indicates minimum requirements (when they have changed) would be helpful. Or a table that lists compatibility, something like that.

Cheers for being on it so quickly!

filmaj commented 3 weeks ago

https://github.com/launchdarkly/js-core/issues/345 is an example of the same problem: the library uses TypeScript syntax that is only supported in newer versions of TS, so consumers using older versions get a compilation error. That team decided to revert the use of the newer syntax in order to improve the compatibility with older TS versions.

I will work on simply reverting the new syntax - it seems easy enough, and if that's all it takes to support TS 4.7, then I think it is worth it for customers/consumers.

The problem of TypeScript version compatibility remains, though. My initial reaction would be "isn't this what peerDependencies in package.json is for?" but then I realize that TypeScript in this situation is a dev dependency 😆 😢 so I don't think that is a viable solution here.

Anyways, I will work on reverting the newer syntax usage this morning and release a 7.3.1. I will file a new issue afterwards to continue the discussion around guaranteeing better TypeScript compatibility and what could be done for that. Will comment here again once 7.3.1 is up.

filmaj commented 3 weeks ago

@slack/web-api v7.3.1 to fix this has been released.

I also added an "integration test" in #1841 that verifies integrating web-api with a small/dummy project that uses TypeScript v4.7.2 compiles OK, to prevent any future changes from causing a similar issue. This, I think, should guarantee compatibility between web-api and TypeScript 4.7.2+ moving forward 🤞