Typescript declaration for `this` object
See original GitHub issueHello everybody this is my first time using this library and I’m wondering if there’s a way to define the return type of the collection
object instead of it returning any
Thanks in advance
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Documentation - Object Types - TypeScript
In JavaScript, the fundamental way that we group and pass around data is through objects. In TypeScript, we represent those through object types....
Read more >TypeScript - Objects - Tutorialspoint
TypeScript - Objects, An object is an instance which contains set of key value pairs. The values can be scalar values or functions...
Read more >TypeScript object Type
The TypeScript object type represents any value that is not a primitive value. · The Object type, however, describes functionality that available on...
Read more >Type definition in object literal in TypeScript - Stack Overflow
@DeuxAlpha this is creating an object literal, not an class object. Also an interface can have methods. If your interface defines a method,...
Read more >How Does The Declare Keyword Work In TypeScript?
In TypeScript, the declare keyword tells the compiler that an object exists (and can be referenced inside your code). It declares the object ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’m not sure—looks like it should be a
Collection
? https://github.com/GraphQLGuide/apollo-datasource-mongodb/blob/master/index.d.ts#L39@GeorgGroenendaal Bit of a punt, but is your problem that
ActualDataType
isn’t derived from Mongoose Document as per Issue 78?I’ve tried to rejig the types to solve both issues but it’s difficult. I think the underlying problem is a need for separation of concerns. The Mongoose datasource needs to be in a separate class, perhaps a separate package, from the MongoClient one. Just to make the typings work.
But, giving it a lot of thought while using this package in anger for a couple of months, I’m beginning to conclude that a better solution might be a Data Source that works with any Data Loader and separate Data Loaders for MongoClient and Mongoose. Planning to give that a try soon, if I don’t find one.