angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

Error when using exported interface

Open slubowsky opened this issue 7 years ago β€’ 18 comments

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

slubowsky avatar Jun 24 '19 20:06 slubowsky

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'

mlc-mlapis avatar Jun 24 '19 21:06 mlc-mlapis

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

ICesarI avatar Jun 24 '19 22:06 ICesarI

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.

martinbu avatar Jun 25 '19 07:06 martinbu

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

dottodot avatar Jun 25 '19 08:06 dottodot

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

alfaproject avatar Jun 25 '19 09:06 alfaproject

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

peter-poki avatar Jun 25 '19 11:06 peter-poki

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

TolgaYigit avatar Jun 25 '19 13:06 TolgaYigit

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

hanreev avatar Jun 25 '19 14:06 hanreev

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

jasefisher avatar Jun 25 '19 14:06 jasefisher

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

geo242 avatar Jun 26 '19 18:06 geo242

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

alan-agius4 avatar Jun 27 '19 20:06 alan-agius4

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

Works like a charm, thank you!

jasefisher avatar Jun 27 '19 21:06 jasefisher

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

alfaproject avatar Jun 28 '19 05:06 alfaproject

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

tscislo avatar Jun 28 '19 07:06 tscislo

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

Same for me.

qortex avatar Jun 28 '19 08:06 qortex

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 avatar Jul 03 '19 23:07 MakesNine

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

MakesNine avatar Jul 10 '19 19:07 MakesNine

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.