I am working on a Firebase project where the frontend is written in Angular. I am using the @angular/fire library.
I defined several interfaces where I use firebase and firestore types.
e.g
export interface SchoolAddress {
street: string;
city: string;
state: string;
region: string;
zip: string;
note: string;
position?: firestore.GeoPoint;
}
Now I would like to share this interface between the frontend in Angular and a backend Cloud Function written on top of the firebase SDK.
The problem is so far I was unable to import types like "GeoPoint"in a way that works with both the two projects
import { firestore } from 'firebase';
Works on the Angular app but not on the backend, the compilation fails.
Angular app package.json
...
"dependencies": {
"@angular/animations": "~10.1.6",
"@angular/cdk": "^10.2.5",
"@angular/common": "~10.1.6",
"@angular/compiler": "~10.1.6",
"@angular/core": "~10.1.6",
"@angular/fire": "^6.0.3",
"@angular/forms": "~10.1.6",
"@angular/localize": "^10.1.6",
"@angular/material": "^10.2.5",
"@angular/platform-browser": "~10.1.6",
"@angular/platform-browser-dynamic": "~10.1.6",
"@angular/router": "~10.1.6",
"firebase": "^7.13.1",
"ngx-wig": "^10.0.1",
"rxjs": "~6.5.4",
"tslib": "^2.0.0",
"zone.js": "~0.10.2"
},
...
Backend pakage.json
...
"dependencies": {
"firebase-admin": "^8.10.0",
"firebase-functions": "^3.6.1"
},
...
I do not want to import the full firebase package in the BE if not needed only to have one type definition. What is the best way to do it?