-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Express getMiddleware and express-serve-static-core type not found #3222
Comments
These type definitions are automatically generated by the TypeScript compiler. The |
The TypeScript compiler is inferring the return type of this method accurately, but emitting `import("express-serve-static-core")` directly into the `apollo-server-express` type definitions. Looking at the `package-lock.json` for the Apollo Server repository, I have a working theory that there are multple `@types/express`'s within this project and that, when resolving the imports in the delcarations, a copy of `express-serve-static-core` is not quite in the right resolution path — potentially due to some package hoisting and module resolution. To be honest, it's just a theory and I only spent about 3 or 4 minutes looking at this, but I hope that this will address #3222 (intentionally not using the keyword "Fixes" here because we'll wait for validation!)
The TypeScript compiler is inferring the return type of this method accurately, but emitting `import("express-serve-static-core")` directly into the `apollo-server-express` type definitions. Looking at the `package-lock.json` for the Apollo Server repository, I have a working theory that there are multple `@types/express`'s within this project and that, when resolving the imports in the delcarations, a copy of `express-serve-static-core` is not quite in the right resolution path — potentially due to some package hoisting and module resolution. To be honest, it's just a theory and I only spent about 3 or 4 minutes looking at this, but I hope that this will address #3222 (intentionally not using the keyword "Fixes" here because we'll wait for validation!)
The TypeScript compiler is inferring the return type of this method accurately, but emitting `import("express-serve-static-core")` directly into the `apollo-server-express` type definitions. Looking at the `package-lock.json` for the Apollo Server repository, I have a working theory that there are multple `@types/express`'s within this project and that, when resolving the imports in the delcarations, a copy of `express-serve-static-core` is not quite in the right resolution path — potentially due to some package hoisting and module resolution. To be honest, it's just a theory and I only spent about 3 or 4 minutes looking at this, but I hope that this will address #3222 (intentionally not using the keyword "Fixes" here because we'll wait for validation!)
@JacksonKearl my bad, I forgot that TS will look trough I'm not sure if TS will always infer the return type explicitly for generated This issue doesn't have a problem for yarn 1.17 with |
It was fixed by #3230 |
@CallMeLaNN Glad that worked! 😄 |
Package name: apollo-server-express
Version: v2.9.0, 5 days ago
TS version: 3.5.3
Expected behavior: No error
Actual behavior: Cannot find module 'express-serve-static-core' when I use
applyMiddleware
and compile using tsc.Description:
The
apollo-server-express/dist/ApolloServer.d.ts
contain this function signature:The generated
import("express-serve-static-core")
as explicit return type here is not accurate. When I dig into express core definition, I believe it should be@types/express-serve-static-core
.Any instruction to compile this package on my local?
The text was updated successfully, but these errors were encountered: