Skip to content

Error when using decorator metadata #4549

@thitemple

Description

@thitemple

I'm playing with TS and Aurelia, so I'm trying to use a decorator.

I have a class as follows:

import {bindable} from "aurelia-framework";

export class NavBar {
  title: string;

  @bindable router = null;
}

And the result javascript file is:

System.register(["aurelia-framework"], function(exports_1) {
    var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
        if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc);
        switch (arguments.length) {
            case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target);
            case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0);
            case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc);
        }
    };
    var __metadata = (this && this.__metadata) || function (k, v) {
        if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
    };
    var aurelia_framework_1;
    var NavBar;
    return {
        setters:[
            function (aurelia_framework_1_1) {
                aurelia_framework_1 = aurelia_framework_1_1;
            }],
        execute: function() {
            NavBar = (function () {
                function NavBar() {
                    this.router = null;
                }
                __decorate([
                    aurelia_framework_1.bindable, 
                    __metadata('design:type', ) // ERROR, MISSING SECOND PARAMETER
                ], NavBar.prototype, "router");
                return NavBar;
            })();
            exports_1("NavBar", NavBar);
        }
    }
});

As you can see, the method call to __metadata is missing a second parameter. If I pass the keyword Object as a second parameter, the code works.

My tsconfig.json file:

{
    "compilerOptions": {
        "target": "es5",
        "module": "system",
        "removeComments": true,
        "declaration": false,
        "noImplicitAny": false,
        "noLib": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "sourceMap": false
    },
    "filesGlob": [
        "./**/*.ts",
        "typings/tsd.d.ts",
        "!./node_modules/**/*.ts",
        "!./jspm_packages/**/*.ts",
        "!./dist/**/*.*"
    ],
    "files": [
        "./src/about.ts",
        "./src/app.ts",
        "./src/main.ts",
        "./src/nav-bar.ts",
        "./src/welcome.ts",
        "./typings/aurelia/aurelia-animator-css.d.ts",
        "./typings/aurelia/aurelia-app-contacts.d.ts",
        "./typings/aurelia/aurelia-binding.d.ts",
        "./typings/aurelia/aurelia-bootstrapper.d.ts",
        "./typings/aurelia/aurelia-dependency-injection.d.ts",
        "./typings/aurelia/aurelia-event-aggregator.d.ts",
        "./typings/aurelia/aurelia-framework.d.ts",
        "./typings/aurelia/aurelia-history-browser.d.ts",
        "./typings/aurelia/aurelia-history.d.ts",
        "./typings/aurelia/aurelia-http-client.d.ts",
        "./typings/aurelia/aurelia-loader-default.d.ts",
        "./typings/aurelia/aurelia-loader.d.ts",
        "./typings/aurelia/aurelia-logging-console.d.ts",
        "./typings/aurelia/aurelia-logging.d.ts",
        "./typings/aurelia/aurelia-metadata.d.ts",
        "./typings/aurelia/aurelia-path.d.ts",
        "./typings/aurelia/aurelia-route-recognizer.d.ts",
        "./typings/aurelia/aurelia-router.d.ts",
        "./typings/aurelia/aurelia-skeleton-navigation.d.ts",
        "./typings/aurelia/aurelia-skeleton-plugin.d.ts",
        "./typings/aurelia/aurelia-task-queue.d.ts",
        "./typings/aurelia/aurelia-templating-binding.d.ts",
        "./typings/aurelia/aurelia-templating-resources.d.ts",
        "./typings/aurelia/aurelia-templating-router.d.ts",
        "./typings/aurelia/aurelia-templating.d.ts",
        "./typings/core-js.d.ts",
        "./typings/es6.d.ts",
        "./typings/node/node.d.ts",
        "./typings/tsd.d.ts",
        "typings/tsd.d.ts"
    ]
}

I'm using TypeScript version 1.7.0

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions