2016-11-19 98 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" 
    ] 
    } 
}