Rxjs: Issues with RxJS 6.4.0 and Angular CLI 6.1.x

Created on 30 Jan 2019  路  17Comments  路  Source: ReactiveX/rxjs

Issue

TL;DR: Angular CLI used TS 2.7 and pulled in RxJS ^6.0.0, RxJS 6 has always used TS 2.8, RxJS 6.4 introduced the first feature that required TS 2.8. ^6.0.0 will update to 6.4, and break you if you're still using TS 2.7.

Summary

As summarized by @cartant and @kwonoj :

  • RxJS 6.0.0 was released on 25 Apr 2018
  • TypeScript 2.8 was released on 28 Mar 2018
  • Angular CLI 6.1.0 was released on 26 Jul 2018, depending upon RxJS ^6.0.0 and TypeScript ~2.7.2
  • It seems that Angular CLI chose RxJS v6 and an at-the-time older version of TS
  • Since the RxJS v6 release, my understanding has been that we were targeting the TS 2.8. That鈥檚 what鈥檚 used in Travis, etc.
  • The PR that introduced ObservedValueOf introduced a conditional type
  • Conditional types are not supported in TS 2.7 - they were introduced in TS 2.8
  • Until conditional types were introduced, it seems that - by chance - we鈥檇 not used any TS features that were in 2.8, but not in 2.7
  • Angular CLI 6.2.0 was released on 7 Sep 2018, depending upon RxJS ~6.2.0 and TypeScript ~2.9.2, so this is an Angular CLI 6.1.x problem only

Fix (TBD)

The current plan to fix this is actually to update RxJS to TS 3.2, as TS 3.1 supports building .d.ts files that target multiple versions of TS. So we should be able to fix this in a patch release, and, even better, put RxJS in a better place to use the newest TS features that could really help us without us needing to do major release.

(EDIT: TS 3.1 does NOT support "building" .d.ts files for multiple versions of TS, we'd need to maintain those by hand, given the limited development bandwidth we have, I'm not sure what we can do here)

Workarounds

EDIT: The core team is currently investigating the impact of this issue and options to fix it

high docs

Most helpful comment

Hi there.

Yes, upgrade Typescript from 2.7.X to 2.8 resolve this issue in our project.

diff --git a/package.json b/package.json index c91361e..77d0383 100644 --- a/package.json +++ b/package.json @@ -73,6 +73,6 @@ "protractor": "~5.3.0", "ts-node": "~5.0.1", "tslint": "~5.9.1", - "typescript": "~2.7.0" + "typescript": "~2.8" } }

All 17 comments

The typesVersions feature is discussed here.

Essentially, it allows a distribution to include .d.ts files in multiple, version-specific directories. The typesVersions feature is used when the package is consumed - to determine from which directory the package's types should be read.

So the first question is: what to we do with ObservedValueOf to avoid the conditional type for the generation of 2.7-compatible types?

It should be noted that in order to solve this, it's looking like we're going to need to increase the npm package size, which will negatively effect Electron users that don't (or can't) bundle.

TS 3.1 supports building .d.ts files that target multiple versions of TS

I can't find a reference to that specific feature. The typesVersion metadata can help for projects using TS 3.1+, but I don't see how it will help projects using TS < 2.8

A more conservative approach would be to revert NotificationKind to a type alias as suggested by @cartant.

The issue with ObservedValueOftype is much less severe as it is a new addition and will not break existing code.

I can't resist to include a tiny rant about TypeScripts reluctance to adhere to semantic versioning for "marketing reasons". This is what got us here 馃槥

@tsvetomir NotificationKind is not the problem; ObservedValueOf is the problem. Construction enums were introduced in TS 2.4.

Have the same issue with the following versions:

json "typescript": "2.7.2", "rxjs": "^6.2.1", "@angular/cli": "^6.0.8",

Here is the error:
ERROR in node_modules/rxjs/internal/types.d.ts(81,44): error TS1005: ';' expected node_modules/rxjs/internal/types.d.ts(81,74): error TS1005: ';' expected. node_modules/rxjs/internal/types.d.ts(81,77): error TS1109: Expression expected.

I've deleted several comments that either provided misinformation or simply stated that the workarounds mentioned in the issue worked.

updated "rxjs": "^6.0.0" to "rxjs": "6.0.0" I get the below error

ERROR in node_modules/rxjs-compat/operator/shareReplay.d.ts(2,10): error TS2305: Module '"/export/appl/fqdprod/jenkins_rd/workspace/CI000000024053883/B2BGatewayUI/Build_Release_1.1/b2bgateway-ui/node_modules/rxjs/internal-compatibility/index"' has no exported member 'ShareReplayConfig'.

Below is the version of rxjs-compat from my package.json

"rxjs-compat": "^6.2.2"

Should I align the version of rxjs-compat based on the change made to rxjs version ? Please advice !

Resolved the above issue by removing the carat:
Updating the rxjs-compat version from "rxjs-compat": "^6.2.2" to "rxjs-compat": "6.2.2"

Hi there.

Yes, upgrade Typescript from 2.7.X to 2.8 resolve this issue in our project.

diff --git a/package.json b/package.json index c91361e..77d0383 100644 --- a/package.json +++ b/package.json @@ -73,6 +73,6 @@ "protractor": "~5.3.0", "ts-node": "~5.0.1", "tslint": "~5.9.1", - "typescript": "~2.7.0" + "typescript": "~2.8" } }

Core Team Notes

We need to provide clearer documentation for folks that what they need to do to resolve this issue, and put it up on the docs site, or at least in a markdown file in the repo.

cc @JWO719

I'll take care of it. One thing that came up to my mind, maybe it also makes sense to add it to the update.angular.io page for the related versions.
@benlesh what do you think of it? I can also create an issue on the angular repo to discuss it there?!

I am having the same issue, and have followed the suggested workarounds, but I am still having an issue.

ERROR in node_modules/rxjs/internal/types.d.ts(81,44): error TS1005: ';' expected.
node_modules/rxjs/internal/types.d.ts(81,74): error TS1005: ';' expected.
node_modules/rxjs/internal/types.d.ts(81,77): error TS1109: Expression expected.
node_modules/rxjs/internal/types.d.ts(82,52): error TS1005: ';' expected.
node_modules/rxjs/internal/types.d.ts(82,88): error TS1005: ';' expected.
node_modules/rxjs/internal/types.d.ts(82,92): error TS1109: Expression expected.``

@blakeghowe The problem can be resolved by upgrading TypeScript to >= 2.8 or by pinning RxJS to 6.3.3. So the one of these two changes needs to be made to your package.json:

  • "typescript": "~2.8.0"
  • "rxjs": "~6.3.3"

Resolved the issue by downgrading rx-compat version to 6.2.
"@types/lodash": "4.14.108",
"lodash": "4.17.10",
"rxjs-compat": "6.2"

this issue can be resolved just by removing ^ from the version number of rxjs in package.json file

Hello Guys, Praneeth72 is absolutely right,
Single solution of this issue is
Open up your package.json file , and from dependencies list you will see rxjs written like below
"rxjs": "^6.3.3",
"rxjs-compat": "^6.3.3",
.................................................
All you have to do is to , remove ^ from both of these, so they will become like
"rxjs": "6.3.3",
"rxjs-compat": "6.3.3",
Once done, install packages again by
npm install
Thats all

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cartant picture cartant  路  3Comments

Agraphie picture Agraphie  路  3Comments

peterbakonyi05 picture peterbakonyi05  路  4Comments

benlesh picture benlesh  路  3Comments

Zzzen picture Zzzen  路  3Comments