Angular-cli: Error when using exported interface

Created on 24 Jun 2019  路  18Comments  路  Source: angular/angular-cli

馃悶 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 - https://github.com/angular/angular-cli/issues/2034#issuecomment-246009829. 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...

ngtoolwebpack high regression bufix

Most helpful comment

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/[email protected] should fix the problem for now.

All 18 comments

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'

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

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/[email protected] should fix the problem for now.

I've seeing the same issue reverting back to [email protected] resolves it.

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

Same problem here but downgrade back to [email protected] resolves it.

Same here. Explicitly installing [email protected] and @angular-cli version 8.0.3 solves the problem.

Same problem here. Downgrading to @angular-devkit/[email protected]

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();
  }
}

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

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

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

Works like a charm, thank you!

Mela, I confirm this issue is fixed but now we are being hit by https://github.com/angular/angular-cli/issues/14888 ):

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

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

Same for me.

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.

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

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

Was this page helpful?
0 / 5 - 0 ratings