Invalid type declaration after upgrading to TS 4.7
See original GitHub issue[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"
}
}
Issue Analytics
- State:
- Created a year ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Announcing TypeScript 4.7 - Microsoft Developer Blogs
When TypeScript finds a .d.ts file in package, it is interpreted based on the containing package. New File Extensions. The type field in ......
Read more >Documentation - Do's and Don'ts - TypeScript
This can be very helpful when you are first migrating a JavaScript project to ... Do use the return type void for callbacks...
Read more >What's new in TypeScript 4.7 - LogRocket Blog
In this article, we'll take a look at each of the new changes in TypeScript 4.7 and understand how we can use them...
Read more >ts-loader - npm
The simple solution is to disable it by using the transpileOnly: true option, but doing so leaves you without type checking and will...
Read more >TypeScript errors and how to fix them
Fixed Code ✔️. You cannot write a function implementation inside a declaration file ( *.d.ts ). You can only declare its signature:.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This should be fixed in v10.3.0. Thanks!
Hi @DebkanchanSamadder Thank you reporting this issue! I think we need to point to the correct type definitions in the
package.json
using thetypes
field. https://devblogs.microsoft.com/typescript/announcing-typescript-4-7/#package-json-exports-imports-and-self-referencingI will create a PR for this. Thanks!