首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >引导函数引发错误TS2346:提供的参数与调用目标的任何签名都不匹配

引导函数引发错误TS2346:提供的参数与调用目标的任何签名都不匹配
EN

Stack Overflow用户
提问于 2016-08-17 17:38:52
回答 1查看 334关注 0票数 0

在对我的代码进行了几天的调试之后,gulp终于可以构建它了,我的main.ts看起来像这样:

代码语言:javascript
复制
   ///<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:

代码语言:javascript
复制
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'))
});
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-08-17 17:42:44

试试这个:

bootstrap(App, [MATERIAL_PROVIDERS, HTTP_PROVIDERS] /* method accepts just one array !? */) .catch(err => console.error(err));

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38993023

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档