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.

Hi there, first of all, thank you for the awesome work!

The issue – is it possible to make Query to be a generic interface? e.g. I am defining a generic repository that accepts a filter parameter that should be Query type of T.

Right now, Query (and it’s properties) accept ‘any’ as a value.

Would be great to have:

export abstract class BaseRepository<T> {
  abstract find(item: Sift.Query<T>): Promise<T>;
  // ...
}

or when filtering arrays:

[{ name: 'foo' }, { name: 'bar' }]
  .filter(sift({ name: 'THIS_MUST_BE_STRING' }));

Thank you.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:22 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
crcncommented, Jun 5, 2020

Awesome! Glad to hear that. Finally I can close this ticket. 👏

1reaction
crcncommented, Jun 5, 2020

Odd, I’m unable to reproduce that particular bug. In any case, I added more type safety around $where ($where?: ((this: TValue) => boolean) | string), so I think the problem is fixed. Let me know if it works.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Generic Types - Learning the Java Language
A generic type is a generic class or interface that is parameterized over types. The following Box class will be modified to demonstrate...
Read more >
Documentation - Generics - TypeScript
Generic Classes. A generic class has a similar shape to a generic interface. Generic classes have a generic type parameter list in angle...
Read more >
Generics in Java - GeeksforGeeks
Types of Java Generics ... Generic Method: Generic Java method takes a parameter and returns some value after performing a task. It is...
Read more >
Generic classes and methods | Microsoft Learn
Learn about generics. Generic types maximize code reuse, type safety, and performance, and are commonly used to create collection classes.
Read more >
Generic Types | Flow
Generics (sometimes referred to as polymorphic types) are a way of abstracting a type away. Imagine writing the following identity function which returns ......
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