Nasser Alghamid
Nasser Alghamid

Reputation: 103

How could I make types work on firebase cloud functions?

Typescript types don't work for firebase-admin: this is tsconfig.json file:

"compilerOptions": {
    "lib": [
      "es6",
      "es2015.promise"
    ],
    "target": "es6",
    "module": "commonjs",
    "moduleResolution": "node",
    "jsx": "react",
    "outDir": ".",
    "rootDir": ".",
    "allowSyntheticDefaultImports": true,
    "noImplicitAny": true,
    "experimentalDecorators": true,
    "preserveConstEnums": true,
    "allowJs": true,
    "sourceMap": true,
    "strictNullChecks": true,
    "typeRoots": [          <------ // I tried to use typeRoots with @google-cloud
      "node_modules/@types"         // but it gives errors on tsc
    ]

@google-cloud/firestore solve typings but when I compile 'tsc' I get:

TS2688: Cannot find type definition file for 'protos'.
TS2688: Cannot find type definition file for 'src'.
TS2688: Cannot find type definition file for 'types'.

Upvotes: 1

Views: 350

Answers (1)

Doug Stevenson
Doug Stevenson

Reputation: 317968

I use the default settings from firebase init while selecting TypeScript as a language, and everything works just fine. There's no typeRoots property set in tsconfig.json. It looks like this:

{
  "compilerOptions": {
    "lib": ["es6"],
    "module": "commonjs",
    "noImplicitReturns": true,
    "outDir": "lib",
    "sourceMap": true,
    "target": "es6"
  },
  "compileOnSave": true,
  "include": [
    "src"
  ]
}

Start with that and progressively add extra things to figure out what's causing problems.

Upvotes: 1

Related Questions