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

Error when using exported interface #14876

Closed
slubowsky opened this issue Jun 24, 2019 · 18 comments · Fixed by #14891
Closed

Error when using exported interface #14876

slubowsky opened this issue Jun 24, 2019 · 18 comments · Fixed by #14891

Comments

@slubowsky
Copy link

slubowsky commented Jun 24, 2019

🐞 Bug report

Command (mark with an x)

- [ ] new
- [ ] build
- [x] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Is this a regression?

Yes, the previous version in which this bug was not present was: 8.0.3

(See "anything else relevant" section, exact bug has appeared and been fixed before)

Description

A clear and concise description of the problem...

Using an exported interface produces an error, app is not served.

🔬 Minimal Reproduction

export an interface:

export interface AppConfig {..}
export let APP_CONFIG = new InjectionToken<AppConfig>('app.config');

Import it elsewhere:
import { APP_CONFIG, AppConfig } from '../app.config';
Use it:

export class MyService {
  constructor(@Inject(APP_CONFIG) config: AppConfig,...
  ...
}

🔥 Exception or Error

ng serve

ERROR in ./src/app/shared/my.service.ts 20:12-21
"export 'AppConfig' was not found in '../app.config'

App is not served. Havent tried build.

🌍 Your Environment

Angular CLI: 8.0.4
Node: 12.4.0
OS: win32 x64
Angular: 8.0.2
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router, service-worker

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.800.4
@angular-devkit/build-angular     0.800.4
@angular-devkit/build-optimizer   0.800.4
@angular-devkit/build-webpack     0.800.4
@angular-devkit/core              8.0.4
@angular-devkit/schematics        8.0.4
@angular/cli                      8.0.4
@angular/pwa                      0.800.4
@ngtools/webpack                  8.0.4
@schematics/angular               8.0.4
@schematics/update                0.800.4
rxjs                              6.5.2
typescript                        3.4.5
webpack                           4.30.0

Anything else relevant?
Had this exact issue almost 3 years ago - #2034 (comment). That issue has so many comments that I forget exactly how it was actually resolved, but it was, and warning eventually went away. Now its back.
At that time it was a warning and was ignorable. This time its an error and app is not served...

@slubowsky slubowsky changed the title Warnings when using exported interface Error when using exported interface Jun 24, 2019
mseemann added a commit to mseemann/angular2-mdl that referenced this issue Jun 24, 2019
@mlc-mlapis
Copy link

mlc-mlapis commented Jun 24, 2019

We have the same problem after upgrading to CLI 8.0.4. The files are imported correctly and are on correct paths, but ng serve still reports that DataFilters are not found in dataFilters.interface.

ERROR in ./src/app/modules/homepage/components/homepage/classes/profileHelpers.class.ts 25:12-23
"export 'DataFilters' was not found in '../../../interfaces/dataFilters.interface'

@ICesarI
Copy link

ICesarI commented Jun 24, 2019

We have a similar issue too. Our pipeline was installing Ng CLI 8.0.4 instead of 8.0.0 so when executing the tests the 'MatDialog' were failing showing the error: Failed: DialogData is not defined
Look a similar example at Dialog

@martinbu
Copy link

Same issue here. It seems that the issue was introduced with version 0.800.4 of the @angular-devkit/build-angular as already stated. If I explicitly install version 0.800.3 my application compiles with no error.

For everyone who needs a temporary solution npm install @angular-devkit/build-angular@0.800.3 should fix the problem for now.

@dottodot
Copy link

I've seeing the same issue reverting back to build-angular@0.800.3 resolves it.

@alfaproject
Copy link

Same problem here. Adding a comment for awareness. ):

@peter-poki
Copy link

Same problem here but downgrade back to build-angular@0.800.3 resolves it.

@alan-agius4 alan-agius4 pinned this issue Jun 25, 2019
@TolgaYigit
Copy link

TolgaYigit commented Jun 25, 2019

Same here. Explicitly installing build-angular@0.800.3 and @angular-cli version 8.0.3 solves the problem.

@hanreev
Copy link

hanreev commented Jun 25, 2019

Same problem here. Downgrading to @angular-devkit/build-angular@0.800.3

@jasefisher
Copy link

It is not just exported interfaces, either. I think it has to do with the @Inject() decorator, because this code has the same problem, where the interface is local to the component.

import { Component, Inject } from '@angular/core';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';

interface Dialog {
  title: string;
  content: string;
}

@Component({
  templateUrl: 'dialog.component.html'
})
export class DialogComponent {
  constructor(
    public dialogRef: MatDialogRef<DialogComponent>,
    @Inject(MAT_DIALOG_DATA) public data: Dialog
  ) {}

  onNoClick(): void {
    this.dialogRef.close();
  }
}

clydin added a commit to clydin/angular-cli that referenced this issue Jun 25, 2019
clydin added a commit to clydin/angular-cli that referenced this issue Jun 25, 2019
clydin added a commit to clydin/angular-cli that referenced this issue Jun 25, 2019
clydin added a commit to clydin/angular-cli that referenced this issue Jun 25, 2019
clydin added a commit to clydin/angular-cli that referenced this issue Jun 25, 2019
clydin added a commit to clydin/angular-cli that referenced this issue Jun 25, 2019
@geo242
Copy link

geo242 commented Jun 26, 2019

Same issue here. Another workaround is to build with AOT.

I am having an issue with 0.800.3 though. I am getting Can't resolve all parameters for AppComponent: (?) when I have a dependency on @ngrx/store

@alan-agius4
Copy link
Collaborator

Version 8.0.5 has been released which contains the fix for the above.

@jasefisher
Copy link

Version 8.0.5 has been released which contains the fix for the above.

Works like a charm, thank you!

@alfaproject
Copy link

Mela, I confirm this issue is fixed but now we are being hit by #14888 ):

@tscislo
Copy link

tscislo commented Jun 28, 2019

I can confirm that it works for me with
"@angular-devkit/build-angular": "^0.800.6",
"@angular-devkit/build-ng-packagr": "^0.800.6",
"@angular/cli": "^8.0.6",

@qortex
Copy link

qortex commented Jun 28, 2019

Mela, I confirm this issue is fixed but now we are being hit by #14888 ):

Same for me.

tsvetomir added a commit to telerik/kendo-angular that referenced this issue Jul 1, 2019
The latest version now correctly imports interfaces, see
angular/angular-cli#14876
abadakhshan added a commit to NarikMe/narik-devextreme-demo that referenced this issue Jul 2, 2019
abadakhshan added a commit to NarikMe/narik-devextreme-starter that referenced this issue Jul 2, 2019
abadakhshan added a commit to NarikMe/narik-material-demo-architectui-admin-template that referenced this issue Jul 2, 2019
abadakhshan added a commit to NarikMe/narik-material-demo-coreui-admin-template that referenced this issue Jul 2, 2019
abadakhshan added a commit to NarikMe/narik-material-starter that referenced this issue Jul 2, 2019
abadakhshan added a commit to NarikMe/narik-nebular-demo that referenced this issue Jul 2, 2019
abadakhshan added a commit to NarikMe/narik-ng-bootstrap-demo that referenced this issue Jul 2, 2019
abadakhshan added a commit to NarikMe/narik-primeng-demo that referenced this issue Jul 2, 2019
tsvetomir added a commit to telerik/kendo-angular that referenced this issue Jul 2, 2019
The latest version now correctly imports interfaces, see
angular/angular-cli#14876
@MakesNine
Copy link

The problem is back when upgrading to: "@angular-devkit/build-angular": "0.801.0"

"@angular-devkit/build-angular": "0.800.5" works fine for us and we experienced this problem with version 0.800.4.

@MakesNine
Copy link

Updating to "@angular-devkit/build-angular": "0.801.1" and "@angular/cli": "8.1.1" fixed the issue.
Thanks,

@alan-agius4 alan-agius4 unpinned this issue Jul 21, 2019
@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 9, 2019
ikjelle pushed a commit to ikjelle/angular-cli that referenced this issue Mar 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.