Skip to content

target es2015 throw on circular dependency: Uncaught ReferenceError component is not defined #14247

Closed
@elvisbegovic

Description

@elvisbegovic

🐞 Bug report

at runtime

Is this a regression?

Yes, was working (target:es5) before targetting to es2015 by default

Description

A clear and concise description of the problem...

🔬 Minimal Reproduction

ng serve with tsconfig.json targetting es2015 throw :
Uncaught ReferenceError: ParentComponent is not defined

  1. In ParentComponent I have @ViewChild(ChildComponent)

  2. On ChildComponent's constructor I have
    constructor( @Inject(forwardRef(() => ParentComponent)) private parent:ParentComponent)

Target es5 everything is ok!

N.B. If you remove circular dependencies types
or in constructor (:ParentComponent) or in viewchild (:ChildComponent)
it works!

  1. Download ap.zip
  2. npm i && ng s
  3. open localhost:4200

🔥 Exception or Error


child.component.ts:9 Uncaught ReferenceError: ParentComponent is not defined
    at Module.ParentComponent (child.component.ts:9)
    at Module../src/app/child.component.ts (child.component.ts:10)
    at __webpack_require__ (bootstrap:78)
    at Module../src/app/parent.component.ts (child.component.ts:9)
    at __webpack_require__ (bootstrap:78)
    at Module../src/app/app.module.ts (app.component.ts:24)
    at __webpack_require__ (bootstrap:78)
    at Module../src/main.ts (main.ts:1)
    at __webpack_require__ (bootstrap:78)
    at Object.2 (main.ts:12)

🌍 Your Environment


Angular CLI: 8.0.0-beta.16
Node: 11.12.0
OS: win32 x64
Angular: 8.0.0-beta.13
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.800.0-beta.16
@angular-devkit/build-angular     0.800.0-beta.16
@angular-devkit/build-optimizer   0.800.0-beta.16
@angular-devkit/build-webpack     0.800.0-beta.16
@angular-devkit/core              8.0.0-beta.16
@angular-devkit/schematics        8.0.0-beta.16
@angular/cli                      8.0.0-beta.16
@ngtools/webpack                  8.0.0-beta.16
@schematics/angular               8.0.0-beta.16
@schematics/update                0.800.0-beta.16
rxjs                              6.4.0
typescript                        3.4.4
webpack                           4.30.0

cc @filipesilva

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions