question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Typescript declaration for `this` object

See original GitHub issue

Hello 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

image

Thanks in advance

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
lorensrcommented, Oct 2, 2021

I’m not sure—looks like it should be a Collection? https://github.com/GraphQLGuide/apollo-datasource-mongodb/blob/master/index.d.ts#L39

0reactions
paulrileycommented, Apr 21, 2022

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found