Closed jblevins1991 closed 4 years ago
Expected 0 arguments, but got 1. ts(2554)
Shouldn't this line mean TypeScript should expect 1 argument? https://github.com/GraphQLGuide/apollo-datasource-mongodb/blob/master/index.d.ts#L31
cc @9at8
Sidenote: findOneById
takes an ObjectID
I wish 😂.
Could my tsconfig.json
be incorrect?
This is caused because a typescript types declaration does not exist. I only found this out by hovering the import statement that is not even highlighted by vs code 😕. I thought a type declaration file was merged in.
The solution was the copy the index.d.ts file from this repo into my node_modules/apollo-datasource-mongodb directory.
@jblevins1991 can you double-check that you have v0.2.4? :sweat_smile:
I would search for apollo-datasource-mongodb
in package-lock.json
or yarn.lock
Let me check my package-lock. I did however rm -rf node modules and delete the package-lock.
My comment above was also pre-mature. It still is broken lol.
"apollo-datasource-mongodb": {
"version": "0.2.4",
"resolved": "https://registry.npmjs.org/apollo-datasource-mongodb/-/apollo-datasource-mongodb-0.2.4.tgz",
"integrity": "sha512-fcdxrY7mJOHLi95QgzCsrF5kivF24sLIIZTSviobws2TjmjtYp+URMbT2uwjdnUm7gSvje+BU0k63SP3If2x+A==",
"requires": {
"apollo-datasource": "^0.3.1",
"apollo-server-caching": "^0.3.1",
"apollo-server-errors": "^2.2.1",
"dataloader": "^1.4.0"
}
},
Yeah, this is definitely wrong. It doesn't have any of the index.d.ts
dependencies either.
I did npm install apollo-datasource-mongodb@0.2.4
. I now see the index.d.ts file. I then rm -rf'd node modules and rm package-lock.json and now do not have the index.d.ts again.
Ah, I can reproduce this.
Apparently index.d.ts
is not there in the package that's distributed. I'm looking into it. We should have a fix soon, and then we can release 0.2.5 for a fix.
Thanks for bringing this up @jblevins1991 !
Thank you for being so quick to reply. I can look into this over the weekend if you would like?
This is from the TypeScript web site https://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html
Note that the "typings" field is synonymous with "types", and could be used as well.
Also note that if your package.json includes the "files" property the "types" property will be ignored. In that case you need to pass your main declaration file to the "files" property as well.
Also note that if your main declaration file is named index.d.ts and lives at the root of the package (next to index.js) you do not need to mark the "types" property, though it is advisable to do so
Thanks for the help @jblevins1991 !
Thanks @jblevins1991 for reporting and researching and @9at8 for fixing! 🤗 Fix published in 0.2.5
I started a Typescript project with Apollo Server and have implemented this module the way the documentation expects. I have a data source as shown below as well as my index.ts file that implements the apollo server.
I get the following Typescript errors:
index.ts
This error is when I attempt to pass
client.db().collection("authors")
to the Authors constructor. This also happens for Posts.author.ts