Skip to content

Invalid type declaration after upgrading to TS 4.7 #1726

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
debkanchan opened this issue May 25, 2022 · 5 comments · Fixed by #1758
Closed

Invalid type declaration after upgrading to TS 4.7 #1726

debkanchan opened this issue May 25, 2022 · 5 comments · Fixed by #1758
Assignees

Comments

@debkanchan
Copy link

[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"
	}
}
@google-oss-bot
Copy link

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

@lahirumaramba
Copy link
Member

lahirumaramba commented Jun 3, 2022

Hi @DebkanchanSamadder Thank you reporting this issue! I think we need to point to the correct type definitions in the package.json using the types field. https://devblogs.microsoft.com/typescript/announcing-typescript-4-7/#package-json-exports-imports-and-self-referencing

I will create a PR for this. Thanks!

@debkanchan
Copy link
Author

Hey @lahirumaramba , Any updates on this? This is a blocker for moving to New ts version

@lotus-x
Copy link

lotus-x commented Jun 9, 2022

Yeah same here, it would be great to have an updated version with the fix.

@lahirumaramba
Copy link
Member

This should be fixed in v10.3.0. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants