Skip to content

Invalid type declaration after upgrading to TS 4.7 #1726

Closed
@debkanchan

Description

@debkanchan

[READ] Step 1: Are you in the right place?

  • For issues related to the code in this repository file a Github issue.
  • If the issue pertains to Cloud Firestore, read the instructions in the "Firestore issue"
    template.
  • For general technical questions, post a question on StackOverflow
    with the firebase tag.
  • For general Firebase discussion, use the firebase-talk
    google group.
  • For help troubleshooting your application that does not fall under one
    of the above categories, reach out to the personalized
    Firebase support channel.

[REQUIRED] Step 2: Describe your environment

  • Operating System version: MacOS Monterey 12.3.1
  • Firebase SDK version: 10.2.0
  • Firebase Product: app, firestore
  • Node.js version: 16
  • NPM version: 8.5.5

[REQUIRED] Step 3: Describe the problem

Steps to reproduce:

After upgrading to Typescript 4.7, tsc throws the following error for all firebase admin SDK imports

error TS7016: Could not find a declaration file for module 'firebase-admin/firestore'. '/Users/debkanchan/Library/Mobile Documents/com~apple~CloudDocs/Work/Ride/Code/Backend/services/wallet-service/node_modules/firebase-admin/lib/esm/firestore/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/firebase-admin` if it exists or add a new declaration (.d.ts) file containing `declare module 'firebase-admin/firestore';`

2 import { Firestore, FieldValue, getFirestore } from "firebase-admin/firestore";

Relevant Code:

tsconfig.json

{
	"extends": "@tsconfig/node16/tsconfig.json",
	"compilerOptions": {
		"module": "Node16",
		"outDir": "build",
		"removeComments": true
		// "noImplicitAny": false
	},
	"compileOnSave": true,
	"include": ["src"]
}

package.json

{
	"type": "module",
	"engines": {
		"node": "16"
	},
       ...
	"dependencies": {
		"firebase-admin": "^10.2.0",
                ...
	},
	"devDependencies": {
		"@tsconfig/node16": "^1.0.2",
                 ...
		"ts-node": "^10.8.0",
		"typescript": "^4.7.2"
	}
}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions