I am using TypeScript and Firebase together.
My class has fireybase: FirebaseInterface; property.
When I initialise it using this.fireybase = new Firebase('URL/');
I get a compile time error about the Firebase object.
The name 'Firebase' does not exist in the current scope
interface FirebaseInterface {
set(s:string): any;
}
I have tried adding a Firebase interface into the library but it still doesn’t like it.
What is the best approach to doing this in TypeScript?
The typescript compiler tells you that it is unable to find type
Firebaseso you need to introduce it. In your case, if the providers of the firebase library want to support development in Typescript, they would need to provide a declarations file that specifies the typeFirebase(and dependendant types). In your case, a simpleFirebase.d.tsfile might look as follows:Firebase.d.ts
Then you need to bring the declarations file into scope with a reference declaration as follows:
MyApp.ts
You can read more about declaration files and reference paths in the language specification.