Reputation: 13063
I would like to use Firebase Cloud Functions with Typescript rather than Javascript. One thing is bothering me: my IDE is not autocompleting me for every Typescript files like it does on Javascript files. This is what I mean:
Package.json:
{
"name": "functions",
"scripts": {
"lint": "tslint --project tsconfig.json",
"build": "tsc",
"serve": "npm run build && firebase serve --only functions",
"shell": "npm run build && firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"main": "lib/index.ts",
"dependencies": {
"firebase-admin": "~5.12.0",
"firebase-functions": "^1.0.1"
},
"devDependencies": {
"tslint": "^5.8.0",
"typescript": "^2.5.3"
},
"private": true
}
It autocompletes every function nicely on .js files, but not on .ts files. I did have chosen Typescript as my language. This happens on every IDE I try.
Upvotes: 0
Views: 200
Reputation: 317750
When using TypeScript, you should use import
statements instead of require
. Try these lines instead:
import * as functions from "firebase-functions"
import * as admin from "firebase-admin"
When you use these, you'll find is that functions
and admin
will give you autocomplete options under their namespace when you type .
after those identifiers.
Upvotes: 3