Firebase InitializeApp in Angular Typescript
<p>I'm attempting to initialize my angular (typescript) app to use firebase. I have A <code>FirebaseService</code> class that has a method to initialize the app, i.e.,</p>

<pre><code>import {Injectable} from "@angular/core";
import * as firebase from 'firebase';

const firebaseConfig = {
    apiKey: // my api key,
    authDomain: // my auth domain,
    databaseURL: // my database url,
    storageBucket: // my storage bucket,
};

@Injectable()
export class FirebaseService {

    start(): void {
        console.log("Starting firebase");
        firebase.initializeApp(firebaseConfig);
    };
}
</code></pre>

<p>I call <code>FirebaseService.Start</code> when the application starts up, but I'm currently getting the following error in the browser console</p>

<pre><code>Starting firebase
core.umd.js:2837 EXCEPTION: Error in :0:0 caused by: firebase.initializeApp is not a functionErrorHandler.handleError @ core.umd.js:2837
core.umd.js:2839 ORIGINAL EXCEPTION: firebase.initializeApp is not a functionErrorHandler.handleError @ core.umd.js:2839
core.umd.js:2842 ORIGINAL STACKTRACE:ErrorHandler.handleError @ core.umd.js:2842
core.umd.js:2843 TypeError: firebase.initializeApp is not a function
    at FirebaseService.start (http://localhost:3000/app/services/firebase.service.js:24:18)
    at new AppComponent (http://localhost:3000/app/app.component.js:16:25)
    at new Wrapper_AppComponent (/AppModule/AppComponent/wrapper.ngfactory.js:7:18)
    at CompiledTemplate.proxyViewClass.View_AppComponent_Host0.createInternal (/AppModule/AppComponent/host.ngfactory.js:20:28)
    at CompiledTemplate.proxyViewClass.AppView.createHostView (http://localhost:3000/lib/@angular/core/bundles/core.umd.js:9147:25)
    at CompiledTemplate.proxyViewClass.DebugAppView.createHostView (http://localhost:3000/lib/@angular/core/bundles/core.umd.js:9407:56)
    at ComponentFactory.create (http://localhost:3000/lib/@angular/core/bundles/core.umd.js:5481:29)
    at ApplicationRef_.bootstrap (http://localhost:3000/lib/@angular/core/bundles/core.umd.js:6550:44)
    at eval (http://localhost:3000/lib/@angular/core/bundles/core.umd.js:6459:93)
    at Array.forEach (native)
</code></pre>

<p>My SystemJS config is set up as follows</p>

<pre><code>(function (global) {
    System.config({
        paths: {
            // paths serve as alias
            "lib:": 'lib/'
        },
        // map tells the System loader where to look for things
        map: {
            // our app is within the app folder

            // angular bundles
            '@angular/core': 'lib:@angular/core/bundles/core.umd.js',
            '@angular/common': 'lib:@angular/common/bundles/common.umd.js',
            '@angular/compiler': 'lib:@angular/compiler/bundles/compiler.umd.js',
            '@angular/platform-browser': 'lib:@angular/platform-browser/bundles/platform-browser.umd.js',
            '@angular/platform-browser-dynamic': 'lib:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
            '@angular/http': 'lib:@angular/http/bundles/http.umd.js',
            '@angular/router': 'lib:@angular/router/bundles/router.umd.js',
            '@angular/forms': 'lib:@angular/forms/bundles/forms.umd.js',
            'rxjs': 'lib:rxjs',
            'firebase': 'lib:firebase'
        },
        // packages tells the System loader how to load when no filename and/or no extension
        packages: {
            app: {
                main: './main.js',
                defaultExtension: 'js'
            },
            rxjs: {
                defaultExtension: 'js'
            },
            firebase: {
                main: 'firebase.js',
                defaultExtension: 'js'
            }
        }
    });
})(this);
</code></pre>

<p>So it should be able to load <code>firebase.js</code> from my <code>lib</code> folder. Looking in <code>firebase.js</code> there certainly appears to be a function called <code>initializeApp</code>, i.e.,</p>

<pre><code>initializeApp:function(a,c){void 0===c?c="[DEFAULT]":"string"===typeof c&amp;&amp;""!....
</code></pre>

<p>so i can't work out where I'm going wrong. Any ideas?</p>

<p>I'm using angular v2.2.0 and firebase v3.6.1</p>