2016-11-19 204 views
1

我已阅读并遵循给出的指示和建议herehere,但仍然无法阻止弹出错误。下面是安装方向,我跟着 The Installation process角度材料2生成错误

这些都是我不断收到 enter image description here

以下的错误是我tsconfig文件

{ 
    "compileOnSave": true, 
    "compilerOptions": { 
"typeRoots": [ "libs/@types" ], 

"emitDecoratorMetadata": true, 
"experimentalDecorators": true, 
"module": "commonjs", 
"noEmitOnError": true, 
"noImplicitAny": false, 
"outDir": "../wwwroot/appScripts/", 
"removeComments": false, 
"sourceMap": true, 
"target": "es6", 
"moduleResolution": "node" 
    }, 
    "exclude": [ 
"node_modules", 
"typings/index", 
"typings/index.d.ts", 
"typings/browser", 
"typings/browser.d.ts" 

    ] 
} 

我gulpfile

var ts = require('gulp-typescript'); 
var gulp = require('gulp'); 
var clean = require('gulp-clean'); 

var destPath = './wwwroot/libs/'; 

gulp.task('clean', function() { 
    return gulp.src(destPath) 
     .pipe(clean()); 
}); 


gulp.task("scriptsNStyles",() => { 
    gulp.src([ 
     'core-js/client/**', 
     'systemjs/dist/system.src.js', 
     'reflect-metadata/**', 
      'rxjs/**', 
      'zone.js/dist/**', 
      'jquery/dist/jquery.*js', 
      'bootstrap/dist/js/bootstrap.*js', 
      'ng2-bootstrap/**', 
      'lodash/**', 
      'moment/**', 
      'symbol-observable/**', 
      'hammerjs/**', 
      'jasmine/**', 
      '@types/**', 
      '@angular/**' 
    ], { 
     cwd: "node_modules/**" 
    }) 
     .pipe(gulp.dest("./wwwroot/libs")); 
}); 

var tsProject = ts.createProject('scripts/tsconfig.json' 
    ,{ typescript: require('typescript') } 
    ); 
gulp.task('ts', function (done) { 
    //var tsResult = tsProject.src(); 
    var tsResult = gulp.src(["scripts/**/*.ts","scripts/**/**/*.ts", "scripts/*.ts"]) 
     .pipe(ts(tsProject), undefined, ts.reporter.fullReporter()); 
    return tsResult.js.pipe(gulp.dest('./wwwroot/appScripts')); 
}); 

gulp.task('watch', ['watch.ts']); 

gulp.task('watch.ts', ['ts'], function() { 
    return gulp.watch('scripts/**/*.ts', ['ts']); 
}); 

gulp.task('default', ['scriptsNStyles', 'watch']); 

我的main.ts文件

/// <reference path="../wwwroot/libs/@types/hammerjs/index.d.ts" /> 

import { platformBrowserDynamic } from "@angular/platform-browser-dynamic"; 
import { AppModule } from "./app.module"; 

platformBrowserDynamic().bootstrapModule(AppModule); 

我失去了一半的头发,试图找出这一个。我确信我一定在某个地方犯了一些愚蠢的错误。

回答

1

好的,所以我解决了我的问题,但我需要有人向我解释为什么我采用的方法几乎可以工作。 我遵循了我能找到的所有建议,以获得Angular资料2.0.0-alpha.10和[email protected]和“@ types/hammerjs @ 2.0.33”一起玩无济于事。 我做了这个“导入”hammerjs'“在我的main.ts它从来没有工作。所以我双击错误列表中的错误之一,并得到了包含该文件个错误

import { MdGestureConfig } from '../core'; 
import 'hammerjs'; 
/** 
* An extension of MdGestureConfig that exposes the underlying HammerManager instances. 
* Tests can use these instances to emit fake gesture events. 
*/ 
export declare class TestGestureConfig extends MdGestureConfig { 
    /** 
    * A map of Hammer instances to element. 
    * Used to emit events over instances for an element. 
    */ 
    hammerInstances: Map<HTMLElement, HammerManager[]>; 
    /** 
    * Create a mapping of Hammer instances to element so that events can be emitted during testing. 
    */ 
    buildHammer(element: HTMLElement): HammerManager; 
    /** 
    * The Angular event plugin for Hammer creates a new HammerManager instance for each listener, 
    * so we need to apply our event on all instances to hit the correct listener. 
    */ 
    emitEventForElement(eventType: string, element: HTMLElement, eventData?: {}): void; 
} 

,并放置以下导入行有

import 'hammerjs' 

和,瞧,所有的错误消失了。 我希望有一些聪明的人在那里会提供一些解释,毕竟这是或不是一个修复。

然而,我有挑战的最后一点处理

Severity Code Description Project File Line Suppression State 
Error TS2309 Build:An export assignment cannot be used in a module with other exported elements. ReportBook.Web C:\Users\Julius\Documents\Projects\School\Development\ReportBook\ReportBook.Web\node_modules\@types\node\index.d.ts 3625  
0

今天我有同样的问题,升级的角度,当从2.0.x的到2.4.x我发现这里的解决方案:你的应用程序的模块上

> npm install --save hammerjs 
> npm install --save-dev @types/hammerjs 

进口HammerJS: https://material2-docs-dev.firebaseapp.com/guide/getting-started

如果要包括来自NPM HammerJS,您可以安装它。

的src /应用/ app.module.ts

> import 'hammerjs'; 

最后,你需要hammerjs添加到您的类型文件tsconfig.json的

部分:

{ 
    "compilerOptions": { 
    "types": [ 
     "hammerjs" 
    ] 
    } 
}