2016-10-22 36 views
0

我最近更新到VSCode 1.6.1,它从Typescript 1.8.10切换到2.0.3,这使我的项目停止工作。VisualStudio代码运行时错误的手稿版本

的思考方法已经改变所以现在路由的控制器试图获得的方法时抛出以下错误属性:

TypeError: Reflect.getMetadata is not a function 
    at exports.Body (C:\FN\FantasyNation\Stormbringer\node_modules\routing-contr 
ollers\decorator\params.js:155:30) 
    at __param (C:\FN\FantasyNation\Stormbringer\Scripts\controllers\UserControl 
ler.js:12:37) 
    at __decorate (C:\FN\FantasyNation\Stormbringer\Scripts\controllers\UserCont 
roller.js:5:110) 
    at Object.<anonymous> (C:\FN\FantasyNation\Stormbringer\Scripts\controllers\ 
UserController.js:56:1) 

继发行说明中的​​指示切换到一个特定的版本在我工作空间我装老打字稿工作区:

npm install [email protected] 

当重新打开VSCode没有问我关于TS版的使用,所以我手动更新我的工作区“settings.json”指定它:

{  
    "files.exclude": { 
     "**/*.js.map": true, 
     "**/*.js": {"when": "$(basename).ts"} 
    }, 
    "editor.stablePeek": true, 
    "typescript.tsdk": "node_modules/typescript/lib" 
} 

当我打开 “的.ts” 文件VSCode显示正确的版本:

enter image description here

但经过重建(Ctrl + Shift + B),并再次运行(F5)我仍然得到完全相同的错误。

我tsconfig是:

{ 
    "compilerOptions": { 
     "target": "es6", 
     "module": "commonjs",   
     "noImplicitAny": false, 
     "removeComments": true,   
     "emitDecoratorMetadata": true, 
     "experimentalDecorators": true, 
     "inlineSourceMap": true, 
     "watch": false 
    }, 
    "exclude": [ 
     "node_modules" 
    ] 
} 

我的启动设置为:

{ 
    "version": "0.2.0", 
    "configurations": [ 
     { 
      "name": "Launch", 
      "type": "node", 
      "request": "launch", 
      "program": "${workspaceRoot}/app.js", 
      "stopOnEntry": false, 
      "args": [], 
      "cwd": "${workspaceRoot}", 
      "runtimeExecutable": null, 
      "runtimeArgs": [ 
       "--nolazy" 
      ], 
      "externalConsole": true, 
      "sourceMaps": true, 
      "outDir": null 
     }, 
     { 
      "name": "Attach", 
      "type": "node", 
      "request": "attach", 
      "port": 5959 
     } 
    ] 
} 

我错过了什么?

回答

0

嗯,这是一个合并,搞砸了代码并移动了导入顺序。

import 'reflect-metadata'; 

应该是第一个进口获得路由控制器工作