在对我的代码进行了几天的调试之后,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.
我不明白为什么这个是从旧的英雄之旅指南中抄袭过来的,而且它本身很简单,为什么会给我这样的错误。我正在尝试寻找旧的bootstrap函数,因为我可能用错了它(这个代码可以在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'))
});发布于 2016-08-17 17:42:44
试试这个:
bootstrap(App, [MATERIAL_PROVIDERS, HTTP_PROVIDERS] /* method accepts just one array !? */) .catch(err => console.error(err));
https://stackoverflow.com/questions/38993023
复制相似问题