Skip to content

Uncaught reflect-metadata shim is required when using class decorators #854

@cmermingas

Description

@cmermingas
  • I'm submitting a ...
    [X] bug report
    [ ] feature request
    [ ] question about the decisions made in the repository
  • Do you want to request a feature or report a bug?
    Report a problem
  • What is the current behavior?
    I see error Uncaught reflect-metadata shim is required when using class decorators on the JavaScript console.
  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem

One of my files is an AI player for a game and I want it to emit an event when it has decided its next move. So, I have this:

export class ConnectFourAiPlayerWebWorker {
  public nextMove = new EventEmitter<number>();

  constructor(public worker: Worker, public playerNumber: number) {
    worker.onmessage = (event: MessageEvent) => this.turnTaken(event);
  }

  takeTurn() {
    this.worker.postMessage('TAKE_TURN');
  }

  turnTaken(event: MessageEvent) {
    this.nextMove.emit(event.data);
  }
}

It was working until I added public nextMove = new EventEmitter<number>();. It then started giving this error in the browser's console: connect-four-ai-player-worker-wrapper.ts?21e7:3 Uncaught reflect-metadata shim is required when using class decorators

  • Please tell us about your environment:
  • Angular version: 2.0.0-rc.4
  • Browser: Chrome 52.0.2743.116
  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, gitter, etc)

I checked #353 but couldn't relate to the exact same problem. Plus, I don't think I would have to change the Webpack configuration or import new packages just to use EventEmitter. So my guess is that something else is wrong and chances are it's user error :-) Thanks in advance for your help!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions