Reputation: 8993
I am attempting the latest Firebase npm module (4.8.1
). I am using the commonjs module system with webpack bundling. In order to ensure I'm getting the typings I need I have the following in my package.json
:
"dependencies: {
"firebase": "^4.8.1"
},
"devDependencies": {
"@firebase/app": "^0.1.5",
"@firebase/app-types": "^0.1.0",
"@firebase/auth": "^0.3.1",
"@firebase/auth-types": "^0.1.0",
"@firebase/database": "^0.1.6",
"@firebase/database-types": "0.1.0",
}
When I transpile with tsc
I get the following errors:
node_modules/@firebase/database/dist/esm/src/api/Database.d.ts(4,33): error TS2307: Cannot find module '@firebase/app-types/private'.
node_modules/@firebase/database/dist/esm/src/core/AuthTokenProvider.d.ts(17,39): error TS2307: Cannot find module '@firebase/app-types/private'.
I find this VERY odd for several reasons:
@firebase/data-types
is there to provide typings rather than implementation code. That's why I have it listed as as devDependency instead of dependency@firebase/*
to "dependencies" it still gives same errorUpvotes: 1
Views: 328
Reputation: 3767
With the following tsconfig.json
it works fine for me:
{
"compilerOptions": {
"target": "es2015",
"module": "commonjs",
"moduleResolution": "node",
"inlineSourceMap": true
}
}
In src/index.ts
I just import like this:
// This import loads the firebase namespace along with all its type information.
import * as firebase from 'firebase';
const firebaseApp = firebase.initializeApp({
apiKey: '<your-api-key>',
authDomain: '<your-auth-domain>',
databaseURL: '<your-database-url>',
storageBucket: '<your-storage-bucket>',
messagingSenderId: '<your-sender-id>'
});
Before I modified my tsconfig.json
I had similar issue with:
{
...
"devDependencies": {
...
},
"dependencies": {
...,
"firebase": "^4.8.1"
}
}
I hope that helps!
Upvotes: 1