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

Upgrade to Aangular V4 fails #14513

Closed
mmrath opened this issue Feb 15, 2017 · 26 comments
Closed

Upgrade to Aangular V4 fails #14513

mmrath opened this issue Feb 15, 2017 · 26 comments
Labels
area: core Issues related to the framework runtime

Comments

@mmrath
Copy link

mmrath commented Feb 15, 2017

I'm submitting a ... (check one with "x")

[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

AOT compilation success with 2.4.7 but fails with 4.0.0-beta.7

Error on console:

ERROR in Can't resolve all parameters for HttpInterceptorService in /Users/murali/Projects/test-ng/src/app/http/interceptors/http-interceptor.service.ts: ([object Object], [object Object], [object Object], ?).

ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in '/Users/murali/Projects/test-ng/src'
 @ ./src/main.ts 4:0-74
 @ multi ./src/main.ts

Expected behavior

AOT compilation should pass with 4.0.0-beta.7

Minimal reproduction of the problem with instructions

A very minimal repo is located at https://github.com/mmrath/ng4-upgrade-test
master branch has code for 4.0.0-beta.7 which is failing to build.
ng2 branch has code for 2.4.7 which builds successfully. The only change here is version numbers for angular packages

To build run npm install and then ng build --prod assuming cli is installed globally

What is the motivation / use case for changing the behavior?

Please tell us about your environment:

@angular/cli: beta 31
node 7.2.1
npm 3.10.10

  • Angular version: 4.0.0-beta.7
  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]
  • Language: Typescript: 2.1.6
  • Node (for AoT issues): node --version = v7.2.1
@DzmitryShylovich
Copy link
Contributor

err msg?

@mmrath
Copy link
Author

mmrath commented Feb 15, 2017

Updated issue description. Error is

ERROR in Can't resolve all parameters for HttpInterceptorService in /Users/murali/Projects/test-ng/src/app/http/interceptors/http-interceptor.service.ts: ([object Object], [object Object], [object Object], ?).

ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in '/Users/murali/Projects/test-ng/src'
 @ ./src/main.ts 4:0-74
 @ multi ./src/main.ts

@vicb
Copy link
Contributor

vicb commented Feb 16, 2017

Typescript version ?

@mmrath
Copy link
Author

mmrath commented Feb 16, 2017

2.1.6

@mmrath
Copy link
Author

mmrath commented Feb 16, 2017

@vicb is there something trivial I am missing here. I have tried to look up breaking charges, but the changelog does not mention this. I am using typescript 2.1 for both 2.4.7 and 4.0 beta, so it may not be typescript issue.

@mmrath mmrath changed the title Upgrade to 4.0.0-beta.7 fails Upgrade to Aangular V4 fails Feb 26, 2017
@mmrath
Copy link
Author

mmrath commented Feb 26, 2017

This is still an issue with rc.1. Is there a workaround or fix?

@Tragetaschen
Copy link
Contributor

I'm getting the same error for a component of mine:

import { Injectable } from '@angular/core';
import { BehaviorSubject } from 'rxjs/Rx';

@Injectable()
export class AlarmService {
    public P1: BehaviorSubject<boolean>;
    public P2: BehaviorSubject<boolean>;

    constructor(p1: boolean, p2: boolean) {
        this.P1 = new BehaviorSubject<boolean>(p1);
        this.P2 = new BehaviorSubject<boolean>(p2);
    }
}

> .\node_modules\.bin\ngc -p .\Client\
Can't resolve all parameters for AlarmService in C:/Users/kairu/Source/Repos/[...]/alarm.service.ts: (?, ?).

It looks like ngc doesn't like built-in types, boolean in my case and an array in your case.

@DzmitryShylovich
Copy link
Contributor

@Tragetaschen did you provide p1 and p2?

@Tragetaschen
Copy link
Contributor

What do you mean? The way I use this service is through

export function defaultAlarmService() {
    return new AlarmService(false, false);
}
// ...
    { provide: AlarmService, useFactory: defaultAlarmService },

@DzmitryShylovich
Copy link
Contributor

@Tragetaschen ensure that you don't have somewhere providers: [AlarmService]

@Tragetaschen
Copy link
Contributor

Done. I have { provide: AlarmService, useFactory: defaultAlarmService }, and { provide: AlarmService, useClass: InstrumentAlarmService },. InstrumentAlarmService itself only has di-able dependencies

@DzmitryShylovich
Copy link
Contributor

paste InstrumentAlarmService

@Tragetaschen
Copy link
Contributor

import { Injectable } from '@angular/core';
import { GuiConnectionService } from './gui-connection.service';
import { AlarmService } from './alarm.service';

@Injectable()
export class InstrumentAlarmService extends AlarmService {
    constructor(guiConnectionService: GuiConnectionService) {
        super(false, false);

        // simplified:
        guiConnectionService.Update
            .subscribe(x => {
                this.P1.next(x.P1);
                this.P2.next(x.P2);
            });
    }
}

@mmrath
Copy link
Author

mmrath commented Feb 27, 2017

@DzmitryShylovich Any chance you can help me with this repo https://github.com/mmrath/ng4-upgrade-test

This fails with beta 7 as well as rc1

@DzmitryShylovich
Copy link
Contributor

@Tragetaschen the same code does work in 2.x with aot, right?

@Tragetaschen
Copy link
Contributor

Tragetaschen commented Feb 27, 2017

Yes, 2.4.8 is what I upgraded to last Friday before going to 4.0.0-rc.1 today

@Tragetaschen
Copy link
Contributor

I've reproduced the issue based on an angular-cli project: https://github.com/Tragetaschen/angular-issue-n14513

The second commit adds two services as above. ngc -p src/tsconfig.app.json from angular ^2.4.0 works.

The third commit upgrades to angular 4.0.0-rc.1 and fails with the above error: Can't resolve all parameters for AlarmService in C:/Users/kairu/Source/Repos/angular-issue-n14513/src/app/alarm.service.ts: (?).

@DzmitryShylovich
Copy link
Contributor

@Tragetaschen interesting. and error disappears when you remove Injectable from AlarmService. looks like a valid bug.

@Tragetaschen
Copy link
Contributor

flag: should remain open!?

@mmrath
Copy link
Author

mmrath commented Mar 1, 2017

The original example repo that I provided contains code from covalent. I see there is a merged PR which resolves the issue. I'll give it a try today

Ref: Teradata/covalent#377

@DzmitryShylovich
Copy link
Contributor

@mmrath did it help?

@alxhub
Copy link
Member

alxhub commented Apr 1, 2017

This appears to be a compiler/metadata issue, not http. Reassigning.

@alxhub alxhub added area: core Issues related to the framework runtime and removed comp: http labels Apr 1, 2017
@mmrath
Copy link
Author

mmrath commented Apr 2, 2017

This is resoved.

@mmrath mmrath closed this as completed Apr 2, 2017
@mmrath
Copy link
Author

mmrath commented Apr 2, 2017

I just had to remove Injectable annotation

@Kyderman
Copy link

Worth noting to anybody who sees this, if you have a normal class you use for just constructing objects, leave out the @Injectable annotation, it seems that from Angular 5 onwards it will cause an error in aot compiling.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: core Issues related to the framework runtime
Projects
None yet
Development

No branches or pull requests

6 participants