Visual Studio 2013 Angular2 rc.1,其中Typescript接收Angular打字稿

时间:2016-05-25 18:48:42

标签: visual-studio-2013 typescript angular

我正在尝试使用VS2013完成Angular2快速入门。我已经安装了Typescript 1.8.5(这是VS2013的最新版本)。我跟随了许多在线指南并拼凑起来为VS2013。当我运行构建时,我在Angular2类型文件中得到了数百个错误,类似于:

  

错误2构建:'='预期。 .. \ ng_for.d.ts 7 14 Angular2Quickstart

这是我的systemjs.config.js:

/**
 * System configuration for Angular 2 samples
 * Adjust as necessary for your application needs.
 */
(function (global) {
    // map tells the System loader where to look for things
    var map = {
        'app': 'app', // 'dist',
        '@angular': 'Scripts/lib/@angular',
        'rxjs': 'Scripts/lib/rxjs'
    };
    // 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' },
        'angular2-in-memory-web-api': { defaultExtension: 'js' },
    };
    var ngPackageNames = [
      'common',
      'compiler',
      'core',
      'http',
      'platform-browser',
      'platform-browser-dynamic',
      'router',
      'router-deprecated',
      'upgrade',
    ];
    // Add package entries for angular packages
    ngPackageNames.forEach(function (pkgName) {
        packages['@angular/' + pkgName] = { main: pkgName + '.umd.js', defaultExtension: 'js' };
    });
    var config = {
        map: map,
        packages: packages
    }
    System.config(config);
})(this);

这是我的package.json:

{
    "name": "angular2demo",
    "version": "1.0.0",
    "license": "ISC",
    "scripts": {
    "postinstall": "typings install",    
    "typings": "typings"
  },
    "dependencies": {
        "@angular/common":  "2.0.0-rc.1",
        "@angular/compiler":  "2.0.0-rc.1",
        "@angular/core":  "2.0.0-rc.1",
        "@angular/http":  "2.0.0-rc.1",
        "@angular/platform-browser":  "2.0.0-rc.1",
        "@angular/platform-browser-dynamic":  "2.0.0-rc.1",
        "@angular/router":  "2.0.0-rc.1",
        "@angular/router-deprecated":  "2.0.0-rc.1",
        "@angular/upgrade":  "2.0.0-rc.1",
        "systemjs": "0.19.27",
        "core-js": "^2.4.0",
        "reflect-metadata": "^0.1.3",
        "rxjs": "5.0.0-beta.6",
        "zone.js": "^0.6.12",
        "angular2-in-memory-web-api": "0.0.9",
        "bootstrap": "^3.3.6"
    },
    "devDependencies": {
        "typescript": "^1.8.11"
    }
}

什么会导致这类错误?

更新:我能够使用gulp和npm tsc编译和运行TS而没有任何问题,只是VS2013编译失败了。

1 个答案:

答案 0 :(得分:0)

我很高兴我可以帮助你。

今天我遇到了同样的问题,我解决了。

我的TS在npm tsc编译得很好,但不仅仅是vs2013,

你需要把它放在项目src,

<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>

:)