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

Issues with RxJS 6.4.0 and Angular CLI 6.1.x #4512

Closed
benlesh opened this issue Jan 30, 2019 · 18 comments
Closed

Issues with RxJS 6.4.0 and Angular CLI 6.1.x #4512

benlesh opened this issue Jan 30, 2019 · 18 comments
Assignees
Labels
docs Issues and PRs related to documentation

Comments

@benlesh
Copy link
Member

benlesh commented Jan 30, 2019

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’s what’s 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’d 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

  • You could update your project to TS 2.8
  • You can pin your project to rxjs@6.3.3

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

@cartant
Copy link
Collaborator

cartant commented Jan 30, 2019

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?

@benlesh
Copy link
Member Author

benlesh commented Jan 30, 2019

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.

@tsvetomir
Copy link

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 😞

@cartant
Copy link
Collaborator

cartant commented Jan 31, 2019

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

@Perl99
Copy link

Perl99 commented Jan 31, 2019

Related question: https://stackoverflow.com/questions/54434333/error-ts1005-expected-typescript-angular-6-for-first-build-error-rxjs-insi

@ddesna
Copy link

ddesna commented Feb 5, 2019

Have the same issue with the following versions:

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

@ReactiveX ReactiveX deleted a comment from nikithaperuka89 Feb 5, 2019
@ReactiveX ReactiveX deleted a comment from sauravraj95 Feb 5, 2019
@ReactiveX ReactiveX deleted a comment from sachin-dbox Feb 5, 2019
@ReactiveX ReactiveX deleted a comment from majorsaaam Feb 5, 2019
@cartant
Copy link
Collaborator

cartant commented Feb 5, 2019

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

vchimev added a commit to NativeScript/sample-Groceries that referenced this issue Feb 6, 2019
vchimev added a commit to NativeScript/sample-Groceries that referenced this issue Feb 6, 2019
vchimev added a commit to NativeScript/sample-Groceries that referenced this issue Feb 6, 2019
* chore: pin rxjs@~6.3.3

Related to ReactiveX/rxjs#4512.

* chore(travis-ci): update IOS_PACKAGE_FOLDER path
@nikithaperuka89
Copy link

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 !

@nikithaperuka89
Copy link

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"

@MefhigosetH
Copy link

MefhigosetH commented Feb 18, 2019

Hi there.

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

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"
     }
 }

@benlesh benlesh removed the AGENDA ITEM Flagged for discussion at core team meetings label Apr 10, 2019
@benlesh
Copy link
Member Author

benlesh commented Apr 10, 2019

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

@benlesh benlesh added priority: high docs Issues and PRs related to documentation and removed priority: critical bug Confirmed bug labels Apr 10, 2019
@niklas-wortmann
Copy link
Member

niklas-wortmann commented May 2, 2019

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?!

@blakeghowe
Copy link

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

@cartant
Copy link
Collaborator

cartant commented Jun 8, 2019

@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"

@sachindevtripathi
Copy link

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

@Praneeth72
Copy link

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

@rashidxp
Copy link

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

@cartant
Copy link
Collaborator

cartant commented May 1, 2021

Closing this 'cause it's two years old, isn't actionable and it's closure won't impact it's discovery via a Google search or whatever.

@cartant cartant closed this as completed May 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Issues and PRs related to documentation
Projects
None yet