Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong generics passed by RxCollection extending RxCollectionBase #6188

Closed
artaommahe opened this issue Jul 7, 2024 · 4 comments
Closed

Wrong generics passed by RxCollection extending RxCollectionBase #6188

artaommahe opened this issue Jul 7, 2024 · 4 comments

Comments

@artaommahe
Copy link

artaommahe commented Jul 7, 2024

RxCollectionBase has 5 generics with Reactivity as a last one. When RxCollection extends RxCollectionBase it passes only 4 of them and instead of passing StaticMethods as 4th the Reactivity is used.

RxCollectionBase<InstanceCreationOptions, RxDocumentType, OrmMethods, Reactivity> &

export type RxCollection<
    RxDocumentType = any,
    OrmMethods = {},
    StaticMethods = {},
    InstanceCreationOptions = {},
    Reactivity = unknown
> = StaticMethods &
    RxCollectionBase<InstanceCreationOptions, RxDocumentType, OrmMethods, Reactivity> &
    RxCollectionGenerated<RxDocumentType, OrmMethods, Reactivity>;

export class RxCollectionBase<

export class RxCollectionBase<
    InstanceCreationOptions,
    RxDocumentType = { [prop: string]: any; },
    OrmMethods = {},
    StaticMethods = { [key: string]: any; },
    Reactivity = any
> {

This leads to wrong types for Reactivity and most likely StaticMethods

export interface DbCollections<Reactivity> {
  smth: RxCollection<Smth, unknown, unknown, unknown, Reactivity>;
}

export type Db = RxDatabase<DbCollections<Signal<unknown>>, unknown, unknown, Signal<unknown>>;

let db: Db;

const data = db.smth.find().$$;
//         ^ any

Btw also looks like even after fixing this issue types for reactivity .$$ will be wrong and always equal passed Reactivity generic value (Signal<unknown> in the example above)

@artaommahe artaommahe closed this as not planned Won't fix, can't repro, duplicate, stale Jul 7, 2024
@artaommahe artaommahe changed the title Wrong generics Wrong generics order in RxCollection extending RxCollectionBase Jul 7, 2024
@artaommahe artaommahe changed the title Wrong generics order in RxCollection extending RxCollectionBase Wrong generics passed by RxCollection extending RxCollectionBase Jul 7, 2024
@artaommahe artaommahe reopened this Jul 7, 2024
@pubkey
Copy link
Owner

pubkey commented Jul 7, 2024

Thanks for investigation. PR is welcomed. I tried to fix the Signal problem some time ago but did not find a solution.

@pubkey
Copy link
Owner

pubkey commented Jul 7, 2024

Fixed in the linked commit. Please test the next release.

@pubkey pubkey closed this as completed in 0657aa2 Jul 8, 2024
@artaommahe
Copy link
Author

@pubkey the type is better now, thx!

as for proper reactivity types looks like it's not possible with the current typescript and requires smth like this to be implemented microsoft/TypeScript#1213

@pubkey
Copy link
Owner

pubkey commented Jul 14, 2024

@artaommahe Thank you for that link. This helps me a lot because I can now stop looking for how to make it work and just wait for that issue to be resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants