【问题标题】:typescript debugging in visual studio 2015 no longer works with Angular 2 2.0.0-rc.1Visual Studio 2015 中的打字稿调试不再适用于 Angular 2 2.0.0-rc.1
【发布时间】:2016-08-30 04:26:23
【问题描述】:

在 Visual Studio 2015 中升级到 Angular 2 rc1 打字稿调试后停止工作。我像以前的版本一样添加了元标记,但这会导致现在关于“要求”未定义的所有其他类型的问题。有没有人能够让这个工作呢?

这是我的 system.config.js 文件

(function (global) {

// map tells the System loader where to look for things
var map = {
    'app': 'app', // 'dist',
    'rxjs': 'node_modules/rxjs',
    '@angular': 'node_modules/@angular'
};

// packages tells the System loader how to load when no filename 
// and/or no extension
var packages = {
    'app': { main: 'main.js', defaultExtension: 'js' },
    'rxjs': { defaultExtension: 'js' },
};
var meta = {
    '*.js': { scriptLoad: true } //this allows TS debugging in VS
};

var packageNames = [
  '@angular/common',
  '@angular/compiler',
  '@angular/core',
  '@angular/http',
  '@angular/platform-browser',
  '@angular/platform-browser-dynamic',
  '@angular/router',
  '@angular/router-deprecated',
  '@angular/testing',
  '@angular/upgrade',
];

// add package entries for angular packages in 
// the form '@angular/common':    {   main: 'index.js', 
// defaultExtension: 'js' }
packageNames.forEach(function (pkgName) {
    packages[pkgName] = { main: 'index.js', defaultExtension: 'js' };
});

var config = {
    meta: meta,
    map: map,
    packages: packages
}

// filterSystemConfig - index.html's chance to modify config before
// we register it.
if (global.filterSystemConfig) { global.filterSystemConfig(config); }

System.config(config);

})(this);

【问题讨论】:

  • 我不会是唯一一个注意到这一点的人吗?

标签: typescript visual-studio-2015 angular


【解决方案1】:

我已经使用 Gulp 从 VS2015 进行了 angular2 调试。你试过 Gulp 吗?以下说明很有帮助: http://www.codeproject.com/Articles/1087605/Angular-typescript-configuration-and-debugging-for.

基本上,我所做的是:

  • 将 gulp 添加到 package.json 中

                 "devDependencies": {    
                      "gulp": "^3.9.1",
                       ...
                  }
    
  • 将gulpfile.js添加到项目的根目录(内容见上面的codeProject链接)

  • 调用Sytem.config时添加元

       System.config({
        meta: {
            '*.js': {
                scriptLoad: true
            }
        },
        packages: {
            app: {
                format: 'register',
                defaultExtension: 'js'
            }
        }
    });
    
    • 重新运行“npm install”

    • 按照说明进行操作:“鼠标右键单击 gulpfile.js 并选择 Task Runner Explorer。鼠标右键单击 moveToLibs 并选择 Run”

【讨论】:

    【解决方案2】:

    解决方法是在 cmd 中为您的项目文件夹运行以下命令

    >tsc
    

    但首先要确保你已经安装了 typescript 编译器

    $ npm install typescript-compiler 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-02-19
      • 1970-01-01
      • 2018-09-08
      • 1970-01-01
      • 2016-07-16
      • 2016-08-29
      • 2016-11-21
      相关资源
      最近更新 更多