Skip to content

ES2015 + emitDecoratorMetadata causes Cannot access before intialization #15077

@pauldraper

Description

@pauldraper

🐞 bug report

Affected Package

@angular/compiler

Is this a regression?

No, but this is more relevant now because angular-cli permits ES2015 targets.

Description

When targeting ES2015, emitDecoratorMetadata causes a ReferenceError.

🔬 Minimal Reproduction

https://github.com/pauldraper/angular-decorator-metadata

ng serve

Load in browser.

🔥 Exception or Error

main.js:98 Uncaught ReferenceError: Cannot access 'AppService' before initialization
    at Module../src/app.component.ts (main.js:98)
    at __webpack_require__ (runtime.js:80)
    at Module../src/app.module.ts (main.js:123)
    at __webpack_require__ (runtime.js:80)
    at Module../src/main.ts (main.js:157)
    at __webpack_require__ (runtime.js:80)
    at Object.0 (main.js:174)
    at __webpack_require__ (runtime.js:80)
    at checkDeferredModules (runtime.js:46)
    at Array.webpackJsonpCallback [as push] (runtime.js:33)

🌍 Your Environment

Angular Version:

Angular 8.1.1

Anything else relevant?

Removing emitDecoratorMetadata, or targeting es5 fixes the problem.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions