Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase 3.0 with typescript

Tags:

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

like image 879
Mufaddal Gulshan Avatar asked May 19 '16 10:05

Mufaddal Gulshan


People also ask

Does Firebase work with TypeScript?

Using an existing TypeScript project With this configuration, a firebase deploy --only functions command builds your TypeScript code and deploys it as functions.


2 Answers

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

like image 194
urish Avatar answered Nov 13 '22 12:11

urish


You can work around this by doing declare var firebase: any;

like image 38
Alex Weber Avatar answered Nov 13 '22 11:11

Alex Weber