自举功能抛出错误TS2346:提供的参数不匹配通话对象的任何签名

问题描述:

几天后调试我的代码,以便能一饮而尽,最后盖了,我main.ts看起来是这样的:自举功能抛出错误TS2346:提供的参数不匹配通话对象的任何签名

///<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')) 
}); 

试试这个:

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

+0

我不能再用相信。这确实有效。我真的不明白为什么当我尝试一些东西在浏览器上运行,然后我去当地,一切都失败了。谢谢很多,你救了我。我接受10分钟过去。顺便说一句,有什么地方我可以检查一下吗?我真的没有找到旧版本的官方文档:/ –

+1

yw! :)我不知道..该网址看起来像它可能是︰https://angular.io/docs/ts/latest/quickstart.html(见最新)..但我不知道是否以及如何查看较旧的文件,抱歉。 – mxii