Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ES2015 + emitDecoratorMetadata causes Cannot access before intialization #15077

Closed
pauldraper opened this issue Jul 12, 2019 · 4 comments
Closed
Labels
area: @ngtools/webpack freq1: low Only reported by a handful of users who observe it rarely severity5: regression type: bug/fix
Milestone

Comments

@pauldraper
Copy link

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

@alan-agius4 alan-agius4 transferred this issue from angular/angular Jul 15, 2019
@alan-agius4
Copy link
Collaborator

Hi, is there a reason why you need emitDecoratorMetadata to be true?

By the way @pauldraper, love your repo.

@alan-agius4 alan-agius4 added area: @ngtools/webpack freq1: low Only reported by a handful of users who observe it rarely severity5: regression type: bug/fix labels Jul 15, 2019
@ngbot ngbot bot added this to the Backlog milestone Jul 15, 2019
@clydin
Copy link
Member

clydin commented Jul 15, 2019

This TypeScript option has a fundamental design limitation with ES2015+ code and is best avoided when targeting such output. As such this is an issue with TypeScript itself and not Angular.

Angular 8+ no longer requires the option. It was also previously only required for JIT mode which is typically only used in development.

@clydin clydin closed this as completed Jul 15, 2019
@piotrpalek
Copy link

Maybe it would be good to check for that when upgrading angular, or mention it in the docs? This just took me quiet a bit to figure out after upgrading from angular 7 -> 8

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: @ngtools/webpack freq1: low Only reported by a handful of users who observe it rarely severity5: regression type: bug/fix
Projects
None yet
Development

No branches or pull requests

4 participants