-
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
Fix Typescript import error: TS1192 module has no default export #2230
Conversation
I get the following error when using the apollo-server-core with typescript (3.2.4) : node_modules/apollo-server-core/dist/types.d.ts:4:8 - error TS1192: Module '"/node_modules/@types/ws/index"' has no default export. import WebSocket from 'ws'; The change fixes this error!
@Arthie: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Meteor Contributor Agreement here: https://contribute.meteor.com/ |
@Arthie I do believe we need to provide a fix here, but can you provide a use-case/code-snippet showing exactly how you're encountering this type error, in usage of |
Just importing ApolloServer from apollo-server-lambda in a file is enough to trigger the error: Here is my typescript config:
I also get a secondary error similar to the first one but in apollo-server-lambda:
|
Fix lambda types import: aws-lambda types has no default export
@abernix Added a new commit to fix the secondary import error. The Summery of this tiny patch: |
We've generally moved away from the star-import pattern which TypeScript also no longer generates with its default `tsc --init` configuration, so it seems to make sense to keep picking exactly what we want since this pattern is no longer forced upon us by TypeScript.
While it would be perfectly fine to use `import *` in this particular case, we've moved away from the star-import pattern in this repository, instead preferring the `esModuleInterop` compiler option which seems to be the direction that TypeScript is moving as it's now the default with `tsc --init`. TypeScript clearly lost its battle with `import *` which many consider to have been an incorrect direction in the first place. Some build tools won't work with star imports, and using them can make some optimizations more difficult. By avoiding this pattern here, hopefully we'll avoid moving back in that direction inadvertently. Here's a read I found at one point which roughly explains: https://itnext.io/great-import-schism-typescript-confusion-around-imports-explained-d512fc6769c2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made a couple follow-up commits to avoid using star-import
s, since we've generally moved toward esModuleInterop
patterns (which is the default with new tsc --init
projects), but this looks great. Thanks for opening this. Hopefully we can get a release cut soon to validate the success.
This has been included in 2.4.3. I plan on promoting it to the
|
Tested version [email protected] and got no errors! Thank you 👍 |
Thank you for this first contribution! |
I get the following error when using the apollo-server-core with typescript (3.2.4) :
The change fixes this error!
TODO: