cloudnc/observable-webworker

Types of property 'schedule' are incompatible

Closed this issue ยท 3 comments

This is an awesome project and is making my life a lot easier. Thanks for putting it together.

I'm getting this issue when I try to use fromWorker in a project using Nx:

Types of property 'schedule' are incompatible.
    Type '<T>(work: (this: import("/Users/{ omitted }/node_modules/rxjs/src/internal/types").SchedulerAction<T>, state?: T) => void, delay?: number, state?: T) => import("/Users/{ omitted }/node_modules/rxjs/src/internal/Subscription").Subscription' is not assignable to type '<T>(work: (this: import("/Users/{ omitted }/node_modules/rxjs/internal/types").SchedulerAction<T>, state?: T) => void, delay?: number, state?: T) => import("/Users/{ omitted }/node_modules/rxjs/internal/Subscription").Subscription'.
      Types of parameters 'work' and 'work' are incompatible.
        The 'this' types of each signature are incompatible.
          Type 'import("/Users/{ omitted }/node_modules/rxjs/src/internal/types").SchedulerAction<T>' is not assignable to type 'import("/Users/{ omitted }/node_modules/rxjs/internal/types").SchedulerAction<T>'.
            Types of property 'schedule' are incompatible.
              Type '(state?: T, delay?: number) => import("/Users/{ omitted }/node_modules/rxjs/src/internal/Subscription").Subscription' is not assignable to type '(state?: T, delay?: number) => import("/Users/{ omitted }/node_modules/rxjs/internal/Subscription").Subscription'.
                Type 'import("/Users/{ omitted }/node_modules/rxjs/src/internal/Subscription").Subscription' is not assignable to type 'import("/Users/{ omitted }/node_modules/rxjs/internal/Subscription").Subscription'.
                  Property '_parentOrParents' is protected but type 'Subscription' is not a class derived from 'Subscription'.

After some googling and testing, it seems like the issue is the same as this issue in the rxjs repo. In run-worker.ts, you have:

import { NotificationKind } from 'rxjs/internal/Notification';

which is apparently what is throwing the error. I copied the code over to my project and replaced that import with this enum (which is what was being imported from the rxjs library):

export enum NotificationKind {
  NEXT = 'N',
  ERROR = 'E',
  COMPLETE = 'C'
}

After that, it works perfectly. I can open a pull request and make the change myself if you want. Or, it's just replacing that one import that fixed my particular issue if you want to make the change.

Keep up the good work!

Ah interesting issue, hah that is a coincidence as I was the one to add that enum to RxJS in the first place: https://github.com/ReactiveX/rxjs/pull/4405/files

Funny that would come back to bite me. I'll fix this shortly

Thanks for the quick response! That's a pretty funny coincidence for sure. Just so you know, there's another similar reference in from-worker-pool.ts where you're importing ObservableInput from rxjs/src/internal/types

๐ŸŽ‰ This issue has been resolved in version 3.2.1 ๐ŸŽ‰

The release is available on:

Your semantic-release bot ๐Ÿ“ฆ๐Ÿš€