Inversifyjs: ReferenceError: __decorate is not defined

Created on 4 Mar 2018  路  3Comments  路  Source: inversify/InversifyJS

Running the first example in the docs
https://github.com/inversify/InversifyJS/blob/master/wiki/classes_as_id.md

Expected Behavior

It should compile without issues

Current Behavior

I obtain the following error:
````/Volumes/Repo/Projects/inversifyjs-playground/dist/app.js:11
Katana = __decorate([
^

ReferenceError: __decorate is not defined
at /Volumes/Repo/Projects/inversifyjs-playground/dist/app.js:11:5
````

Steps to Reproduce (for bugs)

You can just build and run my playground repo:
https://github.com/Deviad/inversifyjs-playground

Your Environment

  • Version used: "inversify": "^4.10.0",
  • Environment name and version (e.g. Chrome 39, node.js 5.4): Node 9.3, Typescript 2.7.2
  • Operating System and version (desktop or mobile): OS X Sierra
  • Link to your project: https://github.com/Deviad/inversifyjs-playground
/Volumes/Repo/Projects/inversifyjs-playground/dist/app.js:11
    Katana = __decorate([
    ^

ReferenceError: __decorate is not defined
    at /Volumes/Repo/Projects/inversifyjs-playground/dist/app.js:11:5
    at Object.<anonymous> (/Volumes/Repo/Projects/inversifyjs-playground/dist/app.js:15:2)
    at Module._compile (module.js:660:30)
    at Object.Module._extensions..js (module.js:671:10)
    at Module.load (module.js:573:32)
    at tryModuleLoad (module.js:513:12)
    at Function.Module._load (module.js:505:3)
    at Function.Module.runMain (module.js:701:10)
    at startup (bootstrap_node.js:194:16)
    at bootstrap_node.js:618:3
question

Most helpful comment

the problem is in your tsconfig.json. Typescript is not creating the __decorate function in the file.

set "noEmitHelpers": false,

All 3 comments

I had to install ts-helpers and enable support for them in tsconfig "importHelpers": true,

the problem is in your tsconfig.json. Typescript is not creating the __decorate function in the file.

set "noEmitHelpers": false,

Yes, correct. Thank you.

Was this page helpful?
0 / 5 - 0 ratings