RxJS version: 5.5.2
Code to reproduce:
In tsconfig.json:
{
"compilerOptions": {
"skipLibCheck": false,
"strictFunctionTypes": true
}
}
import * as Rx from "rxjs";
Expected behavior:
Compiles successfully.
Actual behavior:
Compiler error:
../../node_modules/rxjs/scheduler/VirtualTimeScheduler.d.ts(22,22): error TS2415: Class 'VirtualAction<T>' incorrectly extends base class 'AsyncAction<T>'.
Types of property 'work' are incompatible.
Type '(this: VirtualAction<T>, state?: T | undefined) => void' is not assignable to type '(this: AsyncAction<T>, state?: T | undefined) => void'.
The 'this' types of each signature are incompatible.
Type 'AsyncAction<T>' is not assignable to type 'VirtualAction<T>'.
Property 'index' is missing in type 'AsyncAction<T>'
Additional information:
Workaround: disable strictFunctionTypes OR enable skipLibCheck
I believe this is happening because work is not defined as a method (rather, it's defined as a property), so its parameters are checked contravariantly. If it was defined as a method, the parameters would be checked covariantly.
This could be fixed by defining work as a method in both classes, or defining it as (this: AsyncAction<T>, state?: T) => void in VirtualAction.
same issue
@jgoz thank you for your detail report.
For the second fix option, I guess really we want (this: AsyncAction<T>, state?: T | undefined) => void ?
We're experiencing the problem as well.
I'm also running into this issue.
The same problem for me! Any updates on this?
the same issue.
same issue
also, even after using "skipLibCheck": false, when using Observable.fromEvent() the argument given, which extends node's event emitter, does not match NodeStyleEventEmitter...
same issue here, can you please tell me what are the steps to fix ?
I upgraded to:
"rxjs": "^5.5.6",
"typescript": "^2.6.2"
applying: "skipLibCheck": false,
"strictFunctionTypes": true in tsconfig.json did not solve the error.
To workaround this issue, you need, "skipLibCheck": true, not false. In generally, I would say it is bad practice to skipLibCheck, but since RxJs typings are broken, it is the only way around the issue.
@craftytrickster yeah, I meant "skipLibCheck " : true.
Even when opting out on checking libs, the strict flag makes rxjs's API not compatible with node's types (namely NodeStyleEventEmitter).
The issue in the VirtualTimeScheduler.d.ts file is there with TS 2..7.1 too.
Changing the type if the this parameter of the workmethod from VirtualActionto its basetype AsyncActionin the VirtualTimeScheduler.d.ts file fixes the build issue.
adding "skipLibCheck": true in tsconfig.json causes error with shared npm module,
..\node_modules\mysharedlib\myfile.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
As @colindekker said - the best way is to change the work method parameter to AsyncAction - this will skip the linter error / build error. From my point of view this is one of the best solutions for now - when the package will get updated the problem should also be solved and updated. Since the error is minor.
This issue is fixed in master (thanks to https://github.com/ReactiveX/rxjs/pull/3050), but it seems like master has some other minor issues which stop us from npm linking the latest.
(these)
../rxjs/dist/typings/internal/OuterSubscriber.d.ts:2:10 - error TS2305: Module '"[...]/rxjs/dist/typings/internal/InnerSubscriber"' has no exported member 'InnerSubscriber'.
2 import { InnerSubscriber } from './InnerSubscriber';
~~~~~~~~~~~~~~~
../rxjs/dist/typings/internal/observable/combineLatest.d.ts:7:10 - error TS2305: Module '"[...]/rxjs/dist/typings/internal/InnerSubscriber"' has no exported member 'InnerSubscriber'.
7 import { InnerSubscriber } from '../InnerSubscriber';
~~~~~~~~~~~~~~~
../rxjs/dist/typings/internal/observable/race.d.ts:6:10 - error TS2305: Module '"[...]/rxjs/dist/typings/internal/InnerSubscriber"' has no exported member 'InnerSubscriber'.
6 import { InnerSubscriber } from '../InnerSubscriber';
~~~~~~~~~~~~~~~
../rxjs/dist/typings/internal/types.d.ts:38:13 - error TS2339: Property 'observable' does not exist on type 'SymbolConstructor'.
38 [Symbol.observable]: () => Subscribable<T>;
~~~~~~~~~~
@benlesh Any idea when we might get a new alpha? I'm very new to the codebase, but I could take a swing at those issues if they're not already in progress.
Note that this issue makes the Angular CLI command ng xi18n fail, in a very unintuitive way.
Is there a version of RxJS 5.x not experiencing this?
It might be due to source in my project Antares, but this error that seems to come from inside of RxJS..
CC @alexjoverm - this is from a module I made from your (very nice) starter kit from a few days ago.
> tsc --module commonjs && rollup -c rollup.config.ts && typedoc --out docs --target es6 --theme minimal --mode file src
node_modules/rxjs/scheduler/VirtualTimeScheduler.d.ts(24,15): error TS2416: Property 'work' in type 'VirtualAction<T>' is not assignable to the same property in base type 'AsyncAction<T>'.
Type '(this: VirtualAction<T>, state?: T | undefined) => void' is not assignable to type '(this: AsyncAction<T>, state?: T | undefined) => void'.
The 'this' types of each signature are incompatible.
Type 'AsyncAction<T>' is not assignable to type 'VirtualAction<T>'.
Property 'index' is missing in type 'AsyncAction<T>'.
I believe this should be resolved. If not, please feel freely file new issue.
Most helpful comment
To workaround this issue, you need,
"skipLibCheck": true, not false. In generally, I would say it is bad practice to skipLibCheck, but since RxJs typings are broken, it is the only way around the issue.