How do I get around this "Subject incorrectly extends Observable" error in TypeScript 2.4 and RxJS 5.x?

get around sentence
get around meaning in hindi
get around the city
get around to meaning
get around to doing something meaning
to get around synonym
get around to significado
get at meaning

When I compile, I get the following compiler error in the RxJS declaration files:

node_modules/rxjs/Subject.d.ts(16,22): error TS2415: Class 'Subject<T>' incorrectly extends base class 'Observable<T>'.
  Types of property 'lift' are incompatible.
    Type '<R>(operator: Operator<T, R>) => Observable<T>' is not assignable to type '<R>(operator: Operator<T, R>) => Observable<R>'.
      Type 'Observable<T>' is not assignable to type 'Observable<R>'.
         Type 'T' is not assignable to type 'R'.

What's going on here, and how do I get around this without downgrading to TypeScript 2.3 or earlier?

Solution

RxJS 5.4.2 should now work perfectly with TypeScript 2.4.1. Simply upgrade to 5.4.2+ if possible.

npm install --save rxjs@^5.4.2

If not, the below solution should work.

Why it's happening

TypeScript 2.4 has a strictness change, and Subject<T> isn't lifting to the correct Observable. The signature really should have been

<R>(operator: Operator<T, R>) => Observable<R>

This will be fixed in RxJS 6.

Alternative Solution

Newer versions of RxJS will have this fixed, but as a temporary workaround, you can use the noStrictGenericChecks compiler option.

In tsconfig.json, put it in "compilerOptions" and set it to true.

{
    "compilerOptions": {
        "noStrictGenericChecks": true
    }
}

On the command line it's --noStrictGenericChecks.

get around, From Longman Dictionary of Contemporary Englishget around to something phrasal verbDOto do something that you have been intending to do for some time I  Metrorail and Metrobus are the most convenient ways to get around DC, with Metrobus providing connections for locations not serviced by Metrorail. The Walter E. Washington Convention Center even has a dedicated Metro station serviced by the Yellow and Green lines, and many hotels are conveniently located near Metro stations or bus routes. Metro operates from 5 a.m. to midnight on weekdays and from 7 a.m. to midnight on weekends.

Today, faced this error and solved this pratically with the below three steps. So sharing the same with the hope, it will help others.

Step 1: In the package.json file change the entry as "rxjs": "5.4.2",

Step 2: Delete the node_modules folder from the project,which is present in the root directory

Step 3 : Now ,Right click the package.json file and click restore like as shown below:

Note : It will again create node_module folder with the new files, Now build the solution, hopefully you should not get any build error related to above problem.

get around to something, 3 : to become known or current word got around that he was resigning. Synonyms & Antonyms Example Sentences Learn More about get around. Keep scrolling  To get around this, many people started using VPNs to appear as if they were in, say, the United States so they could watch shows that were region-locked there.

Add

"noStrictGenericChecks": true

in tsconfig.json file

Get Around, Get around definition: To get around a problem or difficulty means to overcome it. | Meaning, pronunciation, translations and examples. If you’re just trying to get around on the continent you’re on, the process is pretty straightforward. If you’re going somewhere you’ve never been before, you’ll want to walk, run, or hop on your mount (ground or flying) and point yourself in the right direction.

I have made the below two changes in package.json file.

1) changed the rxjs version to 5.4.1 in dependencies section.

"dependencies": { "rxjs": "5.4.1" }

2) changed the typescript version to 2.4.0 in devDependencies section.

"devDependencies": { "typescript": "2.4.0" }

I ran 'npm install' command after making the two changes and it worked.

Get around definition and meaning, Let's get around Mary and sing "Happy Birthday" to her. 2. . to manage to go around someone or something. We couldn't get around the fallen tree, so we turned  First, know that the island of Key West is quite small: two miles wide by four miles long. If you decide to not have a car in Old Town, be assured that there are many ways to get around Key West, including: walking, bicycling, taxis, electric rental cars, mopeds, pedi-cabs, city buses, trolleys, and hotel shuttles.

In your Subject class:

change this line:

lift<R>(operator: Operator<T, R>): Observable<T>;

to :

lift<R>(operator: Operator<T, R>): Observable<R>;

Get around, get around meaning: 1. to travel to a lot of places: 2. to be able to go to different places without difficulty…. Learn more. How do you work around User Account Ban? If your user account is banned from a forum or game, it's different than IP ban. If you're using a service from a website or game provider, you'll have to abide by their rules and understand what you're violating.

GET AROUND, get around something meaning: to find a way of dealing with or avoiding a problem: . Learn more. In order to get a Senior DAY PASS, you need to have a Senior TAP CARD (which is orange in color). Once you do, you can purchase a senior DAY PASS at any metro rail station, from any metro bus driver or at any Metro retailer. These special Senior TAP CARDS are intended for people that live in L.A., not for visitors.

GET AROUND SOMETHING, Get-Aroundsex. n. A person, usually a woman, who engages in promiscuous sex, meaning that they often change sex partners. Lauren: "I heard that Monique  Of course you cannot get around it, wouldn't be much of an encryption if you could Your only options are to restore a backup (image) of that drive (if you got one that contains the data before it was encrypted) or to wipe everything and start from scratch. Computer Type: PC/Desktop. System Manufacturer/Model Number: Custom. OS: Windows 10 Pro.

get around, Here are the best ways to get around Washington, DC, from Metrorail and Metrobus to taxis, rental cars and ridesharing apps, as well as walking and biking​.

Comments
  • where do i use this "--noStrictGenericChecks" ?
  • The compilerOptions in your tsconfig.json. Just remove the dashes and set it to true.
  • Can you please help me on this - stackoverflow.com/questions/44817801/… . This happend when my typescript updated to 2.4.1 I think.
  • Except that my typescript 2.4.0 runtime knows nothing about the noStrictGenericChecks option.. and trying to set it causes an error..
  • Thanks a lot for this answer. npm install --save rxjs@^5.4.2 resolves my issue.
  • Fixed the issue for me. You'd think the tutorials on the official Angular website would be up-to-date with the latest versions but that does not appear to be the case.
  • yes you are right and happy that it fixed your problem @breez. Happy sharing..:)
  • A link to a solution is welcome, but please ensure your answer is useful without it: add context around the link so your fellow users will have some idea what it is and why it’s there, then quote the most relevant part of the page you're linking to in case the target page is unavailable. Answers that are little more than a link may be deleted.