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

Error when using decorator metadata #4549

Closed
thitemple opened this issue Aug 30, 2015 · 8 comments
Closed

Error when using decorator metadata #4549

thitemple opened this issue Aug 30, 2015 · 8 comments
Assignees
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@thitemple
Copy link

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

@mhegazy
Copy link
Contributor

mhegazy commented Aug 30, 2015

which version specifically are you suing, what does tsc --version shows?

this looks a lot like #4364 which was fixed last week.

@mhegazy mhegazy added the Needs More Info The issue still hasn't been fully clarified label Aug 30, 2015
@thitemple
Copy link
Author

When I type tsc --version inside my project folder it says: 1.5.3

I have TypeScript installed locally in my project and the package.json says 1.7.0, I installed today using

"devDependencies": {
  "typescript": "Microsoft/TypeScript"
}

@mhegazy
Copy link
Contributor

mhegazy commented Aug 30, 2015

use npm install typescript@next this will get you the nightly release. your dependency declaration will get you the last major version shipped which is 1.5.3.

here is the latest nightly version:

tsc --v
message TS6029: Version 1.7.0-dev.20150830

@thitemple
Copy link
Author

I tried to install typescript@next and got the following error. Any idea why?

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'install',
1 verbose cli   'typescript@next' ]
2 info using npm@2.11.3
3 info using node@v0.12.7
4 verbose install initial load of C:\Users\vinte\Documents\projects\mealcal\package.json
5 warn package.json mealcal@0.1.0 No description
6 warn package.json mealcal@0.1.0 Normalized value of bugs field is an empty object. Deleted.
7 warn package.json mealcal@0.1.0 No README data
8 verbose installManyTop reading scoped package data from C:\Users\vinte\Documents\projects\mealcal\node_modules\aurelia-cli\package.json
9 verbose installManyTop reading scoped package data from C:\Users\vinte\Documents\projects\mealcal\node_modules\aurelia-tools\package.json
10 verbose installManyTop reading scoped package data from C:\Users\vinte\Documents\projects\mealcal\node_modules\browser-sync\package.json
11 verbose installManyTop reading scoped package data from C:\Users\vinte\Documents\projects\mealcal\node_modules\conventional-changelog\package.json
12 verbose installManyTop reading scoped package data from C:\Users\vinte\Documents\projects\mealcal\node_modules\del\package.json
13 verbose installManyTop reading scoped package data from C:\Users\vinte\Documents\projects\mealcal\node_modules\gulp\package.json
14 verbose installManyTop reading scoped package data from C:\Users\vinte\Documents\projects\mealcal\node_modules\gulp-bump\package.json
15 verbose installManyTop reading scoped package data from C:\Users\vinte\Documents\projects\mealcal\node_modules\gulp-changed\package.json
16 verbose installManyTop reading scoped package data from C:\Users\vinte\Documents\projects\mealcal\node_modules\gulp-jshint\package.json
17 verbose installManyTop reading scoped package data from C:\Users\vinte\Documents\projects\mealcal\node_modules\gulp-plumber\package.json
18 verbose installManyTop reading scoped package data from C:\Users\vinte\Documents\projects\mealcal\node_modules\gulp-protractor\package.json
19 verbose installManyTop reading scoped package data from C:\Users\vinte\Documents\projects\mealcal\node_modules\gulp-sourcemaps\package.json
20 verbose installManyTop reading scoped package data from C:\Users\vinte\Documents\projects\mealcal\node_modules\gulp-typescript\package.json
21 verbose installManyTop reading scoped package data from C:\Users\vinte\Documents\projects\mealcal\node_modules\gulp-yuidoc\package.json
22 verbose installManyTop reading scoped package data from C:\Users\vinte\Documents\projects\mealcal\node_modules\jasmine-core\package.json
23 verbose installManyTop reading scoped package data from C:\Users\vinte\Documents\projects\mealcal\node_modules\jshint-stylish\package.json
24 verbose installManyTop reading scoped package data from C:\Users\vinte\Documents\projects\mealcal\node_modules\jspm\package.json
25 verbose installManyTop reading scoped package data from C:\Users\vinte\Documents\projects\mealcal\node_modules\karma\package.json
26 verbose installManyTop reading scoped package data from C:\Users\vinte\Documents\projects\mealcal\node_modules\karma-chrome-launcher\package.json
27 verbose installManyTop reading scoped package data from C:\Users\vinte\Documents\projects\mealcal\node_modules\karma-coverage\package.json
28 verbose installManyTop reading scoped package data from C:\Users\vinte\Documents\projects\mealcal\node_modules\karma-jasmine\package.json
29 verbose installManyTop reading scoped package data from C:\Users\vinte\Documents\projects\mealcal\node_modules\karma-jspm\package.json
30 verbose installManyTop reading scoped package data from C:\Users\vinte\Documents\projects\mealcal\node_modules\object.assign\package.json
31 verbose installManyTop reading scoped package data from C:\Users\vinte\Documents\projects\mealcal\node_modules\require-dir\package.json
32 verbose installManyTop reading scoped package data from C:\Users\vinte\Documents\projects\mealcal\node_modules\run-sequence\package.json
33 verbose installManyTop reading scoped package data from C:\Users\vinte\Documents\projects\mealcal\node_modules\typescript\package.json
34 verbose installManyTop reading scoped package data from C:\Users\vinte\Documents\projects\mealcal\node_modules\vinyl-paths\package.json
35 verbose installManyTop reading scoped package data from C:\Users\vinte\Documents\projects\mealcal\node_modules\yargs\package.json
36 info package.json browser-sync@1.9.2 No license field.
37 info package.json conventional-changelog@0.0.11 license should be a valid SPDX license expression
38 info package.json gulp-plumber@0.6.6 No license field.
39 info package.json gulp-protractor@0.0.12 No license field.
40 info package.json jspm@0.16.2 license should be a valid SPDX license expression
41 info package.json require-dir@0.1.0 No license field.
42 info package.json yargs@2.3.0 license should be a valid SPDX license expression
43 verbose readDependencies loading dependencies from C:\Users\vinte\Documents\projects\mealcal\package.json
44 silly cache add args [ 'typescript@next', null ]
45 verbose cache add spec typescript@next
46 silly cache add parsed spec { raw: 'typescript@next',
46 silly cache add   scope: null,
46 silly cache add   name: 'typescript',
46 silly cache add   rawSpec: 'next',
46 silly cache add   spec: 'next',
46 silly cache add   type: 'tag' }
47 silly addNamed typescript@next
48 verbose addNamed "next" is being treated as a dist-tag for typescript
49 info addNameTag [ 'typescript', 'next' ]
50 silly mapToRegistry name typescript
51 silly mapToRegistry using default registry
52 silly mapToRegistry registry https://registry.npmjs.org/
53 silly mapToRegistry uri https://registry.npmjs.org/typescript
54 verbose addNameTag registry:https://registry.npmjs.org/typescript not in flight; fetching
55 verbose request uri https://registry.npmjs.org/typescript
56 verbose request no auth needed
57 info attempt registry request try #1 at 5:08:21 PM
58 verbose request id f49cf6917c76d4fe
59 verbose etag "4PFPFR6F1CC86O3DPC6R2AG5C"
60 http request GET https://registry.npmjs.org/typescript
61 http 304 https://registry.npmjs.org/typescript
62 silly get cb [ 304,
62 silly get   { date: 'Sun, 30 Aug 2015 21:08:13 GMT',
62 silly get     via: '1.1 varnish',
62 silly get     'cache-control': 'max-age=60',
62 silly get     etag: '"4PFPFR6F1CC86O3DPC6R2AG5C"',
62 silly get     age: '0',
62 silly get     connection: 'keep-alive',
62 silly get     'x-served-by': 'cache-atl6234-ATL',
62 silly get     'x-cache': 'HIT',
62 silly get     'x-cache-hits': '1',
62 silly get     'x-timer': 'S1440968893.599716,VS0,VE114',
62 silly get     vary: 'Accept' } ]
63 verbose etag https://registry.npmjs.org/typescript from cache
64 verbose get saving typescript to C:\Users\vinte\AppData\Roaming\npm-cache\registry.npmjs.org\typescript\.cache.json
65 silly addNameTag next cb for typescript with tag next
66 silly addNamed typescript@1.7.0-dev.20150830
67 verbose addNamed "1.7.0-dev.20150830" is a plain semver version for typescript
68 silly cache afterAdd typescript@1.7.0-dev.20150830
69 verbose afterAdd C:\Users\vinte\AppData\Roaming\npm-cache\typescript\1.7.0-dev.20150830\package\package.json not in flight; writing
70 verbose afterAdd C:\Users\vinte\AppData\Roaming\npm-cache\typescript\1.7.0-dev.20150830\package\package.json written
71 silly install resolved [ { name: 'typescript',
71 silly install resolved     author: { name: 'Microsoft Corp.' },
71 silly install resolved     homepage: 'http://typescriptlang.org/',
71 silly install resolved     version: '1.7.0-dev.20150830',
71 silly install resolved     license: 'Apache-2.0',
71 silly install resolved     description: 'TypeScript is a language for application scale JavaScript development',
71 silly install resolved     keywords: [ 'TypeScript', 'Microsoft', 'compiler', 'language', 'javascript' ],
71 silly install resolved     bugs: { url: 'https://github.com/Microsoft/TypeScript/issues' },
71 silly install resolved     repository:
71 silly install resolved      { type: 'git',
71 silly install resolved        url: 'git+https://github.com/Microsoft/TypeScript.git' },
71 silly install resolved     main: './lib/typescript.js',
71 silly install resolved     typings: './lib/typescript.d.ts',
71 silly install resolved     bin: { tsc: './bin/tsc', tsserver: './bin/tsserver' },
71 silly install resolved     engines: { node: '>=0.8.0' },
71 silly install resolved     devDependencies:
71 silly install resolved      { jake: 'latest',
71 silly install resolved        mocha: 'latest',
71 silly install resolved        chai: 'latest',
71 silly install resolved        browserify: 'latest',
71 silly install resolved        istanbul: 'latest',
71 silly install resolved        'mocha-fivemat-progress-reporter': 'latest',
71 silly install resolved        tslint: 'latest' },
71 silly install resolved     scripts:
71 silly install resolved      { pretest: 'jake tests',
71 silly install resolved        test: 'jake runtests',
71 silly install resolved        build: 'npm run build:compiler && npm run build:tests',
71 silly install resolved        'build:compiler': 'jake local',
71 silly install resolved        'build:tests': 'jake tests',
71 silly install resolved        clean: 'jake clean' },
71 silly install resolved     browser: { buffer: false, fs: false, os: false, path: false },
71 silly install resolved     gitHead: '7f6608b2b929c6057e3be505c94ebb56969e43d1',
71 silly install resolved     _id: 'typescript@1.7.0-dev.20150830',
71 silly install resolved     _shasum: '08ffc0765278758537a9865d84cdbfe43f09acdf',
71 silly install resolved     _from: 'typescript@next',
71 silly install resolved     _npmVersion: '1.4.28',
71 silly install resolved     _npmUser: { name: 'typescript', email: 'typescript@microsoft.com' },
71 silly install resolved     maintainers: [ [Object] ],
71 silly install resolved     dist:
71 silly install resolved      { shasum: '08ffc0765278758537a9865d84cdbfe43f09acdf',
71 silly install resolved        tarball: 'http://registry.npmjs.org/typescript/-/typescript-1.7.0-dev.20150830.tgz' },
71 silly install resolved     directories: {},
71 silly install resolved     _resolved: 'https://registry.npmjs.org/typescript/-/typescript-1.7.0-dev.20150830.tgz',
71 silly install resolved     readme: 'ERROR: No README data found!' } ]
72 info install typescript@1.7.0-dev.20150830 into C:\Users\vinte\Documents\projects\mealcal
73 info installOne typescript@1.7.0-dev.20150830
74 verbose installOne of typescript to C:\Users\vinte\Documents\projects\mealcal not in flight; installing
75 verbose lock using C:\Users\vinte\AppData\Roaming\npm-cache\_locks\typescript-050182ae4f2d6df2.lock for C:\Users\vinte\Documents\projects\mealcal\node_modules\typescript
76 silly install write writing typescript 1.7.0-dev.20150830 to C:\Users\vinte\Documents\projects\mealcal\node_modules\typescript
77 verbose unbuild node_modules\typescript
78 silly gentlyRm C:\Users\vinte\Documents\projects\mealcal\node_modules\typescript is being purged from base C:\Users\vinte\Documents\projects\mealcal
79 verbose gentlyRm don't care about contents; nuking C:\Users\vinte\Documents\projects\mealcal\node_modules\typescript
80 silly vacuum-fs Error: EPERM, lstat 'C:\Users\vinte\Documents\projects\mealcal\node_modules\typescript'
80 silly vacuum-fs     at Error (native)
81 verbose unlock done using C:\Users\vinte\AppData\Roaming\npm-cache\_locks\typescript-050182ae4f2d6df2.lock for C:\Users\vinte\Documents\projects\mealcal\node_modules\typescript
82 verbose stack Error: EPERM, lstat 'C:\Users\vinte\Documents\projects\mealcal\node_modules\typescript'
82 verbose stack     at Error (native)
83 verbose cwd C:\Users\vinte\Documents\projects\mealcal
84 error Windows_NT 6.3.9600
85 error argv "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "typescript@next"
86 error node v0.12.7
87 error npm  v2.11.3
88 error path C:\Users\vinte\Documents\projects\mealcal\node_modules\typescript
89 error code EPERM
90 error errno -4048
91 error Error: EPERM, lstat 'C:\Users\vinte\Documents\projects\mealcal\node_modules\typescript'
91 error     at Error (native)
91 error  { [Error: EPERM, lstat 'C:\Users\vinte\Documents\projects\mealcal\node_modules\typescript']
91 error   errno: -4048,
91 error   code: 'EPERM',
91 error   path: 'C:\\Users\\vinte\\Documents\\projects\\mealcal\\node_modules\\typescript' }
92 error Please try running this command again as root/Administrator.
93 verbose exit [ -4048, true ]
94 verbose unbuild node_modules\typescript
95 silly gentlyRm C:\Users\vinte\Documents\projects\mealcal\node_modules\typescript is being purged from base C:\Users\vinte\Documents\projects\mealcal
96 verbose gentlyRm don't care about contents; nuking C:\Users\vinte\Documents\projects\mealcal\node_modules\typescript
97 silly vacuum-fs Error: EPERM, lstat 'C:\Users\vinte\Documents\projects\mealcal\node_modules\typescript'
97 silly vacuum-fs     at Error (native)
98 error error rolling back Error: EPERM, lstat 'C:\Users\vinte\Documents\projects\mealcal\node_modules\typescript'
98 error error rolling back     at Error (native)
98 error error rolling back  { [Error: EPERM, lstat 'C:\Users\vinte\Documents\projects\mealcal\node_modules\typescript']
98 error error rolling back   errno: -4048,
98 error error rolling back   code: 'EPERM',
98 error error rolling back   path: 'C:\\Users\\vinte\\Documents\\projects\\mealcal\\node_modules\\typescript' }

@mhegazy
Copy link
Contributor

mhegazy commented Aug 30, 2015

looks like the location on disk is locked by some other process. i would try restarting :)

@thitemple
Copy link
Author

Ok. Now I'm running version 1.7.0-dev.20150830.

I recompiled the project and I had the same result.

@mhegazy mhegazy added the Bug A bug in TypeScript label Aug 31, 2015
@mhegazy mhegazy removed the Needs More Info The issue still hasn't been fully clarified label Aug 31, 2015
@mhegazy
Copy link
Contributor

mhegazy commented Aug 31, 2015

@sheetalkamat can you take a look.

@sheetalkamat
Copy link
Member

Looking into it now.

@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Sep 4, 2015
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

3 participants