Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v4.1.1 has inconsistent types with express v5 #2354

Closed
nickdirienzo opened this issue Dec 4, 2024 · 4 comments · Fixed by #2355
Closed

v4.1.1 has inconsistent types with express v5 #2354

nickdirienzo opened this issue Dec 4, 2024 · 4 comments · Fixed by #2355
Labels
bug M-T: confirmed bug report. Issues are confirmed when the reproduction steps are documented dependencies Pull requests that update a dependency file TypeScript-specific
Milestone

Comments

@nickdirienzo
Copy link

@slack/bolt version

4.1.1

Your App and Receiver Configuration

N/A

Node.js runtime version

v21.7.3

Steps to reproduce:

Install @slack/bolt latest which installs express v5. The express types are set to ^4 in @slack/bolt's package.json but these aren't aligned with the version of Express being used.

Expected result:

@types/express should be 5.0.0 if Express v5 is used as far as I know.

Actual result:

@types/express v4 is used even though express v5 is installed.

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. 🙇

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

@nickdirienzo nickdirienzo changed the title Slack v4.1.1 has inconsistent types with express v5 v4.1.1 has inconsistent types with express v5 Dec 4, 2024
@zimeg zimeg added bug M-T: confirmed bug report. Issues are confirmed when the reproduction steps are documented TypeScript-specific dependencies Pull requests that update a dependency file and removed untriaged labels Dec 4, 2024
@zimeg zimeg added this to the 4.x milestone Dec 4, 2024
@zimeg
Copy link
Member

zimeg commented Dec 4, 2024

Hey @nickdirienzo 👋 Thanks for catching this!

As I understand, the major version of @types/express should match express which is done in #2355. That PR also moves this into devDependencies since I believe it's used during development of bolt-js itself and not during app development.

Could you share how you stumbled into this? I'm wondering if it was caused by incompatible @types/express and express versions, but haven't run into this myself 🤔

@nickdirienzo
Copy link
Author

Thanks for jumping on this so quickly @zimeg! I didn't realize @types/express was pinned to ^4, so in our package.json we had it on 5.0.0 because of the express 5 upgrade. It looks like that PR should resolve the typing issue 🙏

What we're seeing in our development experience is we have a function like this:

import { json as JsonMiddleware, type IRouter, Router } from "express";

// This is getting typed with v5
export const setupApiRoutes = (router: IRouter) => {
	router.use("/v1", apiRouter);
};

Trying to pass in receiver.router causes TS to think a v4 Express router is being passed in even though it expects a v5 one... 😅

import { App, ExpressReceiver } from "@slack/bolt";

const receiver = new ExpressReceiver({
	signingSecret: env.SLACK_SIGNING_SECRET,
	clientId: env.SLACK_CLIENT_ID,
	clientSecret: env.SLACK_CLIENT_SECRET,
	stateSecret: env.SLACK_STATE_SECRET,
	scopes,
	installerOptions: {
		directInstall: true,
	},
	installationStore: InstallationStore,
});

// This errors for us in our IDE
setupApiRoutes(receiver.router);

@zimeg zimeg modified the milestones: 4.x, 4.1.2 Dec 5, 2024
@zimeg
Copy link
Member

zimeg commented Dec 5, 2024

🎉 Thanks so much for sharing this snippet! I can confirm the latest changes fix the compilation error this was causing.

We have a release candidate prepared for the next patch version in #2347 which is undergoing testing now, but I'm hoping to land this change with the next release soon!

@nickdirienzo
Copy link
Author

So speedy! Thanks for following up on this so quickly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug M-T: confirmed bug report. Issues are confirmed when the reproduction steps are documented dependencies Pull requests that update a dependency file TypeScript-specific
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants