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

Strict type versions in apollo-server-express require update #5350

Closed
electerious opened this issue Jun 22, 2021 · 4 comments · Fixed by #5352
Closed

Strict type versions in apollo-server-express require update #5350

electerious opened this issue Jun 22, 2021 · 4 comments · Fixed by #5352

Comments

@electerious
Copy link

electerious commented Jun 22, 2021

apollo-server-express strictly uses @types/express in version 4.17.11 and @types/express-serve-static-core in version 4.17.19. Both should either be updated to 4.17.12 and 4.17.21 or they should not strictly use outdated versions (^4.17.11 and ^4.17.19). The new versions are containing a fix for the following TS errors:

../../node_modules/.pnpm/@types+express-serve-static-core@4.17.19/node_modules/@types/express-serve-static-core/index.d.ts:589:18 - error TS2430: Interface 'Response<ResBody, Locals, StatusCode>' incorrectly extends interface 'ServerResponse'.
  Property 'req' is optional in type 'Response<ResBody, Locals, StatusCode>' but required in type 'ServerResponse'.

589 export interface Response<
                     ~~~~~~~~

../../node_modules/.pnpm/@types+express@4.17.11/node_modules/@types/express/index.d.ts:58:55 - error TS2344: Type 'Response<any, Record<string, any>>' does not satisfy the constraint 'ServerResponse'.
  Property 'req' is optional in type 'Response<any, Record<string, any>>' but required in type 'ServerResponse'.

58     var static: serveStatic.RequestHandlerConstructor<Response>;
                                                         ~~~~~~~~

Here are the specified versions in the package.json:

"@types/express": "4.17.11",
"@types/express-serve-static-core": "4.17.19",

Related:

DefinitelyTyped/DefinitelyTyped#46639 (comment)
DefinitelyTyped/DefinitelyTyped#52775

@glasser
Copy link
Member

glasser commented Jun 22, 2021

This is fixed on the active development branch, release-3.0. We are currently working on finalizing that release and are not as focused on AS2 now.

Is there any workaround here? These versions do work with each other; is the problem some conflict with a third party package? If there's no workaround I can spend some time on a patch release today.

@charles-hill-work
Copy link

@glasser I've spent the past hour trying different package versions, including rolling back a minor version or two. And, haven't gotten past this error.

glasser added a commit that referenced this issue Jun 22, 2021
Our versions for `@types/express` and `@types/express-serve-static-core`
have gotten a bit out of date. They are already upgraded on
`release-3.0` but that's not quite `latest` yet. Somehow despite the
fact that neither `express` nor `serve-static` have had a new version in
two years, the DefinitelyTyped packages for them keep getting
backwards-incompatible changes. This is apparently helpful for some
users who have upgraded some other packages.

Because of how finicky these types are (eg specific `@types/express`
versions depends on specific `@types/express-serve-static-core` versions
without appropriate version dependencies between them) I do generally
think it's best to depend on exact versions here. However I also don't
want to have to make any more AS2 releases. So I'm making these into
caret dependencies but don't intend to make a similar change on
`release-3.0`.

Fixes #5350.
glasser added a commit that referenced this issue Jun 22, 2021
Our versions for `@types/express` and `@types/express-serve-static-core`
have gotten a bit out of date. They are already upgraded on
`release-3.0` but that's not quite `latest` yet. Somehow despite the
fact that neither `express` nor `serve-static` have had a new version in
two years, the DefinitelyTyped packages for them keep getting
backwards-incompatible changes. This is apparently helpful for some
users who have upgraded some other packages.

Because of how finicky these types are (eg specific `@types/express`
versions depends on specific `@types/express-serve-static-core` versions
without appropriate version dependencies between them) I do generally
think it's best to depend on exact versions here. However I also don't
want to have to make any more AS2 releases. So I'm making these into
caret dependencies but don't intend to make a similar change on
`release-3.0`.

Fixes #5350.
@glasser
Copy link
Member

glasser commented Jun 22, 2021

Ok, see if 2.25.2 makes you happier!

@charles-hill-work
Copy link

That solved it. Thanks!!

P.S. I did find a brute-force workaround using npm-force-resolutions. But that will force the same version on all instances of the nested dependency, which may break other stuff.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants