经过几天调试我的代码以便gulp最终可以构建它,我的main.ts看起来像这样:
///<reference path="../typings/jquery/jquery.d.ts" />
//main entry point
import {bootstrap} from 'angular2/platform/browser';
import {App} from './app';
import {MATERIAL_PROVIDERS} from "ng2-material/all";
import {HTTP_PROVIDERS} from 'angular2/http';
bootstrap(App, [MATERIAL_PROVIDERS], [HTTP_PROVIDERS])
.catch(err => console.error(err));
我收到以下错误:src\main.ts(9,1): error TS2346: Supplied parameters do not match any signature of call target.
我无法弄清楚为什么这个,从旧的英雄导游中复制而来,并且本身很简单,就是给我这样的错误。我正在尝试寻找旧的引导函数,因为我可能使用它错了(这段代码适用于plunker,所以我不确定是否会出现这种情况),而且我不确定我是不是甚至看着正确的地方。
有人介意帮助我吗?我正在使用beta.8版本并使用gulp进行转换。
Gulp.js:
var gulp = require('gulp'),
rename = require('gulp-rename'),
traceur = require('gulp-traceur'),
webserver = require('gulp-webserver')
typescript = require('gulp-typescript');
// run init tasks
gulp.task('default', ['dependencies', 'ts', 'js', 'html', 'css']);
// run development task
gulp.task('dev', ['watch', 'serve']);
// serve the build dir
gulp.task('serve', function () {
gulp.src('build')
.pipe(webserver({
open: true,
port: 8070
}));
});
// watch for changes and run the relevant task
gulp.task('watch', function () {
gulp.watch('src/**/*.ts', ['ts']);
gulp.watch('src/**/*.js', ['js']);
gulp.watch('src/**/*.html', ['html']);
gulp.watch('src/**/*.css', ['css']);
});
// move dependencies into build dir
gulp.task('dependencies', function () {
return gulp.src([
'node_modules/traceur/bin/traceur-runtime.js',
'node_modules/systemjs/dist/system-csp-production.src.js',
'node_modules/systemjs/dist/system.js',
'node_modules/reflect-metadata/Reflect.js',
'node_modules/angular2/bundles/angular2.js',
'node_modules/angular2/bundles/angular2-polyfills.js',
'node_modules/rxjs/bundles/Rx.js',
'node_modules/es6-shim/es6-shim.min.js',
'node_modules/es6-shim/es6-shim.map'
])
.pipe(gulp.dest('build/lib'));
});
gulp.task('ts', function () {
return gulp.src(['src/**/*.ts', 'node_modules/angular2/typings/browser.d.ts'])
.pipe(typescript(
{
"target": "es5",
"module": "system",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false
}))
.pipe(gulp.dest('src'));
});
// transpile & move js
gulp.task('js', function () {
return gulp.src('src/**/*.js')
.pipe(rename({
extname: ''
}))
.pipe(traceur({
modules: 'instantiate',
moduleName: true,
annotations: true,
types: true,
memberVariables: true
}))
.pipe(rename({
extname: '.js'
}))
.pipe(gulp.dest('build/src'));
});
// move html
gulp.task('html', function () {
return gulp.src('src/**/*.html')
.pipe(gulp.dest('build'))
});
// move css
gulp.task('css', function () {
return gulp.src('src/**/*.css')
.pipe(gulp.dest('build/src'))
});
答案 0 :(得分:2)
试试这个:
bootstrap(App, [MATERIAL_PROVIDERS, HTTP_PROVIDERS] /* method accepts just one array !? */)
.catch(err => console.error(err));