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

Error in project with TS 2.6 and strictFunctionTypes #3031

Closed
jgoz opened this issue Nov 1, 2017 · 19 comments
Closed

Error in project with TS 2.6 and strictFunctionTypes #3031

jgoz opened this issue Nov 1, 2017 · 19 comments

Comments

@jgoz
Copy link

jgoz commented Nov 1, 2017

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.

@kentrino
Copy link

kentrino commented Nov 3, 2017

same issue
@jgoz thank you for your detail report.

@rhoboat
Copy link

rhoboat commented Nov 5, 2017

For the second fix option, I guess really we want (this: AsyncAction<T>, state?: T | undefined) => void ?

@laurilehmijoki
Copy link

We're experiencing the problem as well.

@brycesteinhoff
Copy link

I'm also running into this issue.

@lednhatkhanh
Copy link

The same problem for me! Any updates on this?

@kentrino
Copy link

kentrino commented Jan 1, 2018

the same issue.

@amir-arad
Copy link

same issue

@amir-arad
Copy link

also, even after using "skipLibCheck": false, when using Observable.fromEvent() the argument given, which extends node's event emitter, does not match NodeStyleEventEmitter...

@MoAsmar
Copy link

MoAsmar commented Jan 29, 2018

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.

@craftytrickster
Copy link

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.

@amir-arad
Copy link

@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).

@colindekker
Copy link

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 work method from VirtualAction to its basetype AsyncAction in the VirtualTimeScheduler.d.ts file fixes the build issue.

@MoAsmar
Copy link

MoAsmar commented Feb 22, 2018

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.

@nvwebd
Copy link

nvwebd commented Feb 27, 2018

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.

@bitjson
Copy link

bitjson commented Mar 8, 2018

This issue is fixed in master (thanks to #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.

@jnizet
Copy link

jnizet commented Apr 27, 2018

Note that this issue makes the Angular CLI command ng xi18n fail, in a very unintuitive way.

@deanrad
Copy link

deanrad commented May 17, 2018

Is there a version of RxJS 5.x not experiencing this?

@deanrad
Copy link

deanrad commented May 18, 2018

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>'.

@kwonoj
Copy link
Member

kwonoj commented Sep 6, 2018

I believe this should be resolved. If not, please feel freely file new issue.

@kwonoj kwonoj closed this as completed Sep 6, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Oct 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests