Firebase & Typescript

1,844 views
Skip to first unread message

Christoffer Skog

unread,
Jan 23, 2016, 9:32:53 AM1/23/16
to Firebase Google Group
I was wondering if there's a way to implement Firebase in a Typescript environment? From what I can see there isn't, but since Angular 2 will be using Typescript (as well as Javascript) it would make sense that this is at least under development. Does anyone know?  

Tom Larkworthy

unread,
Jan 23, 2016, 1:25:26 PM1/23/16
to Firebase Google Group
So there are 3rd party definitions for the Firebase API in DefinatelyTyped https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/firebase/firebase.d.ts

But you can't really type the objects stored in a NoSQL-like database, as they are, almost by definition, untyped objects. 

Tom


On Sat, Jan 23, 2016 at 6:32 AM, Christoffer Skog <chrill...@gmail.com> wrote:
I was wondering if there's a way to implement Firebase in a Typescript environment? From what I can see there isn't, but since Angular 2 will be using Typescript (as well as Javascript) it would make sense that this is at least under development. Does anyone know?  

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/91189d66-315a-4155-bc9d-2e4c98520e92%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Christoffer Skog

unread,
Jan 24, 2016, 1:37:09 PM1/24/16
to Firebase Google Group
I didn't fully understand that.. So I can use Firebase with Typescript if I download the file you posted and include it in my project?

Erik Beeson

unread,
Jan 24, 2016, 2:02:58 PM1/24/16
to fireba...@googlegroups.com
TypeScript is a superset of JavaScript, which means anything that's valid JavaScript, is valid TypeScript. In that sense, the Firebase JavaScript client library works just fine with TypeScript without needing to do anything special.

The main advantage of TypeScript is that it brings strong typing to JavaScript. Type information can even be added to third party libraries without having to modify the original source code by using type definition files. By adding type definitions, your developer tools (code editor, IDE, compiler, etc) can flag errors that would have been missed had the type definition not been there.

So, in summary, Firebase works just fine with TypeScript, and if you want you can optionally take advantage of stronger type definitions using the firebase.d.ts file that Tom already linked to (which comes from DefinitelyTyped; a large repository of TypeScript definitions that people have made for most popular JavaScript libraries).

Hope that helps!

--Erik



Christoffer Skog

unread,
Jan 25, 2016, 7:41:23 AM1/25/16
to Firebase Google Group
Ah I see, I'll look into it more then! :) Thanks!
Reply all
Reply to author
Forward
0 new messages