Generic types?
See original GitHub issueHi 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:
- Created 3 years ago
- Reactions:2
- Comments:22 (10 by maintainers)
Top 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 >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 FreeTop 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
Top GitHub Comments
Awesome! Glad to hear that. Finally I can close this ticket. 👏
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.