nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.58k stars 2.36k forks source link

DataPersistence is throwing a build error (using Ivy) #2405

Closed jessejohnsohn closed 4 years ago

jessejohnsohn commented 4 years ago

Expected Behavior

This is a very basic implementation of an ngrx effect using the DataPersistence.navigation method.

I expected the project to build; although, this is using Angular v9, which isn't officially supported yet.

Current Behavior

The build fails with a lengthy error message (provided below).

Failure Information (for bugs)

`ERROR in src/app/+state/app.effects.ts:15:7 - error TS2322: Type '(_r: ActivatedRouteSnapshot, _state: AppState) => Observable<ActionCreator<"[App] App Launched", () => TypedAction<"[App] App Launched">>>' is not assignable to type '(a: ActivatedRouteSnapshot, state?: AppState) => void | Action | Observable'. Type 'Observable<ActionCreator<"[App] App Launched", () => TypedAction<"[App] App Launched">>>' is not assignable to type 'void | Action | Observable'. Type 'Observable<ActionCreator<"[App] App Launched", () => TypedAction<"[App] App Launched">>>' is not assignable to type 'Observable'. The types of 'source.operator.call' are incompatible between these types. Type '(subscriber: import("C:/dev/NxDataPersistenceBug/node_modules/rxjs/internal/Subscriber").Subscriber, source: any) => import("C:/dev/NxDataPersistenceBug/node_modules/rxjs/internal/types").TeardownLogic' is not assignable to type '(subscriber: import("C:/dev/NxDataPersistenceBug/node_modules/@nrwl/angular/node_modules/rxjs/internal/Subscriber").Subscriber, source: any) => import("C:/dev/NxDataPersistenceBug/node_modules/@nrwl/angular/node_modules/rxjs/internal/types").TeardownLogic'. Types of parameters 'subscriber' and 'subscriber' are incompatible. Property '_parentOrParents' is missing in type 'import("C:/dev/NxDataPersistenceBug/node_modules/@nrwl/angular/node_modules/rxjs/internal/Subscriber").Subscriber' but required in type 'import("C:/dev/NxDataPersistenceBug/node_modules/rxjs/internal/Subscriber").Subscriber'.

15 run: (_r: ActivatedRouteSnapshot, _state: AppState) => {


  node_modules/rxjs/internal/Subscription.d.ts:23:15
    23     protected _parentOrParents: Subscription | Subscription[];
'_parentOrParents' is declared here.

node_modules/@nrwl/angular/src/runtime/nx/data-persistence.d.ts:33:5 33 run(a: ActivatedRouteSnapshot, state?: T): Observable | Action | void;


    The expected type comes from property 'run' which is declared here on type 'HandleNavigationOpts<AppState>'`

### Steps to Reproduce

Please provide detailed steps for reproducing the issue.

1. Clone this [repo](https://github.com/jessejohnsohn/NxDataPersistencePossibleBug)
2. Npm install
3. Ng build
4. Observe error

(

If you can provide steps to reproduce from scratch, that would be enormously appreciated (i.e. where the first step is `npx create-nx-workspace@latest repro-workspace`)

### Context

Please provide any relevant information about your setup:

"dependencies": {
    "@angular/animations": "~9.0.0-rc.11",
    "@angular/cdk": "~9.0.0-rc.8",
    "@angular/common": "~9.0.0-rc.11",
    "@angular/compiler": "~9.0.0-rc.11",
    "@angular/core": "^9.0.0-rc.11",
    "@angular/flex-layout": "^9.0.0-beta.28",
    "@angular/forms": "~9.0.0-rc.11",
    "@angular/material": "^9.0.0-rc.8",
    "@angular/platform-browser": "~9.0.0-rc.11",
    "@angular/platform-browser-dynamic": "~9.0.0-rc.11",
    "@angular/router": "~9.0.0-rc.11",
    "@ngrx/effects": "^8.6.0",
    "@ngrx/entity": "^8.6.0",
    "@ngrx/router-store": "^8.6.0",
    "@ngrx/store": "^8.6.0",
    "@ngrx/store-devtools": "^8.6.0",
    "@nrwl/angular": "^8.12.0",
    "@nrwl/workspace": "^8.12.0",
    "rxjs": "^6.5.3",
    "tslib": "^1.10.0",
    "zone.js": "~0.10.2"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^0.900.0-rc.10",
    "@angular-devkit/build-ng-packagr": "~0.900.0-rc.10",
    "@angular/cli": "^9.0.0-rc.10",
    "@angular/compiler-cli": "~9.0.0-rc.11",
    "@angular/language-service": "~9.0.0-rc.11",
    "@ngrx/schematics": "^8.6.0",
    "@types/node": "^13.5.1",
    "codelyzer": "^5.0.0",
    "ng-packagr": "^9.0.0-rc.7",
    "prettier": "^1.19.1",
    "ts-node": "^8.6.2",
    "tsickle": "^0.38.0",
    "tslint": "~5.15.0",
    "typescript": "^3.7.5"
  }

**A minimal reproduction scenario allows us to quickly confirm a bug (or point out coding problem) as well as confirm that we are fixing the right problem.**

### Failure Logs

Error message provided above.

## Other

I know this is Ivy and Typescript 3.7.5, but I'm really curious about why this is breaking. Even if you don't fix it right away, if you can give me some sort of advice as to where to look in the source code.
jessejohnsohn commented 4 years ago

Update: copying the data-persistence.ts file locally and referencing it fixes the problem. So I'm guessing it's some sort of dependency issue?

FrozenPandaz commented 4 years ago

This won't be the case after #2264 lands.

The reason you are seeing this error message is because the typings are using two different versions of rxjs. If you can align them, it might work. However, I recommend waiting for the official release.

FrozenPandaz commented 4 years ago

Hopefully this answers your question. I am going to close this issue. You can reopen it if something is unclear :)

stijnvn commented 4 years ago

@FrozenPandaz I still see this problem after upgrading to nx 9.0.2. Should this be already fixed?

stijnvn commented 4 years ago

Removing package-lock.json and regenerating it with npm install seems to resolve the dependency problem.

github-actions[bot] commented 1 year ago

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.