Firebase 3.0 with typescript

Mufaddal Gulshan picture Mufaddal Gulshan · May 19, 2016 · Viewed 11.8k times · Source

I am trying to develop a web app with angular2 and firebase 3.0 authentication following the guidelines given by google. However all the guides for web have javascript examples.

I added below lines in my index.html

<script src="https://www.gstatic.com/firebasejs/live/3.0/firebase.js"></script>
var config = {
   apiKey: "AIzaSyCSfBMvAdEDpcm-z6gWp2XXXXXXXXXXXXX",
   authDomain: "fototrans-calculator.firebaseapp.com",
   databaseURL: "https://fototrans-calculator.firebaseio.com",
   storageBucket: "fototrans-calculator.appspot.com",
};
firebase.initializeApp(config);

But when i try to use

rootRef = firebase.database.ref();

I get an error on 'firebase' saying

[ts] Cannot find name 'firebase'.

Now I remember that I had installed firebase using typings for the previous version of Firebase. Do we have any such thing again for the new version of Firebase? Please guide.

Thanks in advance

Answer

urish picture urish · Aug 4, 2016

As of Firebase 3.2.1, the typings are included as part of the official NPM package:

https://firebase.google.com/support/release-notes/js#wzxhzdk4version_321_-_july_26_2016wzxhzdk5