mobxjs / mobx-angular

The MobX connector for Angular.
MIT License
483 stars 59 forks source link

Support Angular 9.0.0 #112

Closed turansky closed 4 years ago

turansky commented 4 years ago
// package.json dependencies
"dependencies": {
    "@angular/animations": "^9.0.0-rc.9",
    "@angular/common": "^9.0.0-rc.9",
    "@angular/compiler": "^9.0.0-rc.9",
    "@angular/core": "^9.0.0-rc.9",
    "@angular/forms": "^9.0.0-rc.9",
    "@angular/platform-browser": "^9.0.0-rc.9",
    "@angular/platform-browser-dynamic": "^9.0.0-rc.9",
    "@angular/router": "^9.0.0-rc.9",
    "mobx": "5.14.2",
    "mobx-angular": "^3.1.0",
    "typescript": "^3.7.5"
}
// ERROR
ERROR in Failed to compile entry-point mobx-angular (module as esm5) due to compilation errors:
node_modules/mobx-angular/dist/mobx-angular.js:26:35 - error NG1010: Expected array when reading the NgModule.declarations of MobxAngularModule

26                     declarations: __spreadArrays(DIRECTIVES),

Is it known problem? Is there known solution for it?

kubk commented 4 years ago

Hi @turansky As a temporary workaround you may use 3.0.3 version, run npm i mobx-angular@3.0.3 to install. NG 9 is still a release candidate, so there might be some issues.

Hi @adamkleingit it looks like the spread syntax in module declaration triggers an error in NG 9: https://github.com/mobxjs/mobx-angular/blob/243fdfe851571679e761f696c3806f59651d7fac/lib/mobx-angular.ts#L26 There are similar issues: https://github.com/angular/angular/issues/29835, https://github.com/coryrylan/ngx-lite/pull/23

I'll create a fix soon.

turansky commented 4 years ago

@kubk, thank you for workaround. Will it be fixed in 3.* version?

kubk commented 4 years ago

Hi @turansky Angular 9 RC 11 should contain a fix for this issue: https://github.com/angular/angular/commit/d749dd3ea1865c2ff7252415227e0210bea96983

Can you confirm updating to RC 11 works for you?

turansky commented 4 years ago

Hi @kubk! Angular 9.0.0-rc.13 + MobX 3.1.0 doesn't work (same problem). Angular 9.0.0-rc.13 + MobX 3.0.3 works fine.

kubk commented 4 years ago

It doesn't work for me either. @adamkleingit It seems like this fix is still required: https://github.com/mobxjs/mobx-angular/pull/113

johnbwoodruff commented 4 years ago

Just checked with a fresh Angular 9 project (official stable release as of earlier today) and this version doesn't work. Downgrading mobx-angular to 3.0.3 does work as a workaround until a fix is released.

juliocardosoventura commented 4 years ago

ERROR in Failed to compile entry-point angular-tree-component (module as esm5) due to compilation errors: node_modules/angular-tree-component/node_modules/mobx-angular/dist/mobx-angular.d.ts:5:22 - error NG6002: Appears in the NgModule.imports of TreeModule, but could not be resolved to an NgModule class

5 export declare class MobxAngularModule {

"@angular/core": "~9.0.0", "mobx-angular": "3.1.0", "mobx-angular": "3.0.3",

How do you fix this... it’s still a problem!

kubk commented 4 years ago

Hi @turansky please try 3.1.1, it should work. Hi @juliocardosoventura , angular-tree-component package requires 3.0.3 version: https://github.com/500tech/angular-tree-component/blob/master/package.json#L70 The error described in this issue is only reproducible on 3.1.0.

turansky commented 4 years ago

Hi @turansky please try 3.1.1, it should work.

It works! @kubk thank you!

kubk commented 4 years ago

@turansky Great, would you mind closing this issue?

turansky commented 4 years ago

Fixed in 3.1.1

debender495 commented 4 years ago

I get below error with angular 9

node_modules/mobx/lib/api/flow.d.ts:9:108 - error TS2304: Cannot find name 'AsyncGenerator'.

9 export declare function flow<R, Args extends any[]>(generator: (...args: Args) => Generator<any, R, any> | AsyncGenerator<any, R, any>): (...args: Args) => CancellablePromise;

kubk commented 4 years ago

@debender495 This is a known issue and it is related to TypeScript, not Mobx: https://github.com/mobxjs/mobx/pull/2225/files#diff-b0aca01070f80bb35c361f0308eb0170R15