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

Warnings when using an exported interface in a class

Open Maistho opened this issue 10 years ago • 140 comments

1. OS

Arch Linux

Linux maistho-laptop 4.7.2-1-ARCH #1 SMP PREEMPT Sat Aug 20 23:02:56 CEST 2016 x86_64 GNU/Linux

2. Versions

angular-cli: 1.0.0-beta.11-webpack.8
node: 6.5.0
os: linux x64

3. Repro steps

I started a new repository, and added a new empty service, with an exported interface.

Complete changes, and a repo to pull and see the issue, can be found here:

https://github.com/Maistho/angular-cli-input-issue/commit/e5c483081bfd7af3dafd0db074179b3090668e27

After running ng build, I get two warnings in the Terminal

4. The log given by the failure

Hash: 354e709ba2cf588db59a                                                                                                                                                                                          
Version: webpack 2.1.0-beta.21
Time: 11161ms
            Asset       Size  Chunks             Chunk Names
   main.bundle.js    2.51 MB    0, 2  [emitted]  main
 styles.bundle.js    10.2 kB    1, 2  [emitted]  styles
        inline.js    5.53 kB       2  [emitted]  inline
         main.map     3.1 MB    0, 2  [emitted]  main
       styles.map    14.1 kB    1, 2  [emitted]  styles
       inline.map    5.59 kB       2  [emitted]  inline
       index.html  489 bytes          [emitted]  
assets/.npmignore    0 bytes          [emitted]  
chunk    {0} main.bundle.js, main.map (main) 2.46 MB {1} [initial] [rendered]
chunk    {1} styles.bundle.js, styles.map (styles) 9.96 kB {2} [initial] [rendered]
chunk    {2} inline.js, inline.map (inline) 0 bytes [entry] [rendered]

WARNING in ./src/app/app.component.ts
18:55 export 'TestInterface' was not found in './test.service'

WARNING in ./src/app/app.component.ts
18:88 export 'TestInterface' was not found in './test.service'
Child html-webpack-plugin for "index.html":
         Asset     Size  Chunks       Chunk Names
    index.html  2.82 kB       0       
    chunk    {0} index.html 357 bytes [entry] [rendered]

5. Mention any other details that might be useful.

I could not reproduce the issue without adding the @Input() to the class member.

Compiling with tsc does not produce any warnings.

Maistho avatar Sep 09 '16 17:09 Maistho

This issue is happening. I have a one big ts file with many interfaces defined. Only two of those interfaces are causing this warning during build. However I'm able to import the interfaces just fine and intellisense is working for the affected interfaces. The stack trace shows the warning is triggered by the cli package. I assume this is ok to ignore as long as it build properly?

yangwen2 avatar Jan 09 '18 21:01 yangwen2

I assume this is ok to ignore as long as it build properly?

yes @yangwen2

jeanpchr avatar Jan 10 '18 12:01 jeanpchr

In case anyone's looking for it, this appears to be the upstream webpack issue that @TheLarkInn mentioned!

https://github.com/webpack/webpack/issues/7378

andrew-humu avatar Nov 27 '18 19:11 andrew-humu

In my case, restarting ng serve helped. I had only one export in my ts file

Maxim-Mazurok avatar Dec 07 '18 19:12 Maxim-Mazurok

I just restarted the server and the warnings are gone.

pradeepbp1310 avatar Mar 04 '19 10:03 pradeepbp1310

This is not an issue anymore. I used abstract class instead.

imrjack avatar Mar 19 '19 21:03 imrjack

This is not an issue anymore. I used abstract class instead.

is there any impact on types if we change interface to abstract class

Aviking88 avatar Jun 19 '19 04:06 Aviking88

Got this issue today when updating angular's packages to 8.0.4 / 0.800.4

https://github.com/angular/angular-cli/issues/2034#issuecomment-249813801 fixed it for me

mpgo13 avatar Jun 25 '19 23:06 mpgo13

Having this issue after upgrading to angular 8

hijazikaram avatar Jun 26 '19 15:06 hijazikaram

Having this issue after upgrading to angular 8

Just move out app the interface/types from the problematic file into a separate *.ts file and don't add the actual code there.

th0r avatar Jun 26 '19 15:06 th0r

@th0r do you mean the interface thats causing the issue to remove them and put them into there own separate file

hijazikaram avatar Jun 26 '19 15:06 hijazikaram

@hijazikaram yes. In my projects in case of such errors I just move all the interfaces/types from the file that triggers an error into a separate file e.g. <filename>.types.ts and export all of them. Also this file should not contain any real code e.g. classes, functions, variable etc.

th0r avatar Jun 26 '19 16:06 th0r

Same issue. Moving interface to a separate file doesn't help if use barrel.

evgeniyefimov avatar Jun 26 '19 17:06 evgeniyefimov

Same issue. really don't want to move interfaces to separate files. Also, issue for aggregator ts files that do a lot of export * from.

jeffwhelpley avatar Jun 26 '19 17:06 jeffwhelpley

@jeffwhelpley I just added | null which fixed the issue for me

hijazikaram avatar Jun 26 '19 19:06 hijazikaram

Why is angular/typescript making it hard for us? 😞

hijazikaram avatar Jun 26 '19 19:06 hijazikaram

same as @mpgo13. I started getting the issue when updated to version 8.0.4 / 0.800.4,

But in my case #2034 (comment) didn't work for me.

Error is not just happening within my own libs, but also in one of the ngrx libraries

tbnovaes avatar Jun 26 '19 19:06 tbnovaes

@tbnovaes I got the same issue few days ago. After setting the fixed version of angular devDependencies to 8.0.0 / 0.800.0 it was gone.

dmitry-urenev avatar Jun 27 '19 06:06 dmitry-urenev

For those of you who got this error after upgrading to 8.0.4 / 0.800.4, see https://github.com/angular/angular-cli/issues/14876. A fix seems to be coming in the next release.

larrifax avatar Jun 27 '19 07:06 larrifax

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.