angelnikolov / ts-cacheable

Observable/Promise Cache Decorator
https://npmjs.com/package/ts-cacheable
ISC License
340 stars 42 forks source link

Observable<XXXXXX>>' is not assignable to parameter of type 'TypedPropertyDescriptor<ICacheable<Observable<any>>>'. #125

Closed hsq125 closed 1 year ago

hsq125 commented 1 year ago

The following


import { Cacheable } from 'ts-cacheable';

[...]

@Cacheable({maxAge: 2 * 60 * 1000 })
public getEvents(): Observable<GetEventsResponse> {
    [...]
}

gives the following compilation error

Error: src/app/event.service.ts:30:4 - error TS2345: Argument of type 'TypedPropertyDescriptor<(eventId: string) => Observable<SPEvent>>' is not assignable to parameter of type 'TypedPropertyDescriptor<ICacheable<Observable<any>>>'.
  Type '(eventId: string) => Observable<SPEvent>' is not assignable to type 'ICacheable<Observable<any>>'.
    Call signature return types 'Observable<SPEvent>' and 'Observable<any>' are incompatible.
      The types of 'source' are incompatible between these types.
        Type 'import("/home/detailoc/dev/workspaces/sp-website/node_modules/rxjs/dist/types/internal/Observable").Observable<any>' is not assignable to type 'import("/home/detailoc/dev/workspaces/sp-website/node_modules/ts-cacheable/node_modules/rxjs/dist/types/internal/Observable").Observable<any>'.

30   @Cacheable({maxAge: 2 * 60 * 1000})

It was however working perfectly with ngx-cacheable.

geraparra commented 1 year ago

I've got the same error any idea?

angelnikolov commented 1 year ago

@hsq125 @geraparra What versions of rxjs are you running? We have made a mistake here and added rxjs as a dependency. Will fix that now.

hsq125 commented 1 year ago

@hsq125 @geraparra What versions of rxjs are you running?

I'm running "rxjs": "~7.5.5",

hsq125 commented 1 year ago

@angelnikolov I upgraded to version 1.0.9 and it works! Thanks for the fix.