我的angular应用程序遇到了一个奇怪的问题,我刚刚将AngularFire添加到我的项目中,但是当我尝试将其添加到项目中时,它显示以下错误:
ERROR in nodae_modules/@angular/fire/angularfire2.d.ts(37,49): error TS2344: Type 'T[K]' does not satisfy the constraint '(...args: any[]) => any'.
node_modules/@angular/fire/angularfire2.d.ts(40,49): error TS2344: Type 'T[K]' does not satisfy the constraint '(...args: any[]) => any'.
node_modules/@angular/fire/angularfire2.d.ts(48,78): error TS2344: Type 'T[K]' does not satisfy the constraint '(...args: any[]) => any'.
node_modules/@angular/fire/angularfire2.d.ts(48,107): error TS2344: Type 'T[K]' does not satisfy the constraint '(...args: any[]) => any'.
node_modules/@angular/fire/angularfire2.d.ts(50,75): error TS2344: Type 'T[K]' does not satisfy the constraint '(...args: any[]) => any'.
node_modules/@angular/fire/angularfire2.d.ts(50,96): error TS2344: Type 'T[K]' does not satisfy the constraint '(...args: any[]) => any'.
我是Angular和AngularFire的新手,我认为这是TypeScript的问题,所以这是tsconfig.json
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"module": "esnext",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"importHelpers": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2018",
"dom"
]}}
有人能帮我一下吗?
提前谢谢。
发布于 2020-05-12 01:48:54
您必须在tsconfig.json中设置一些选项。错误来自node_modules/@angular/fire/angularfire2.d.ts。
tsconfig:
{
//...
compilerOptions: {
"skipLibCheck": true,
//...
}
}
skipLibCheck:此选项用于跳过声明文件的类型检查。
发布于 2020-05-12 22:49:43
我发现了问题的核心,我的Ng版本是7.3.9,而AngularFire是6.0.0,我不得不将版本降级到5.4.2。这完美地解决了我的问题。
感谢开发人员的帮助。
建议:在向项目添加依赖项之前,检查两个版本非常重要。
发布于 2020-06-10 22:49:44
如果您的Angular CLI: 7.2.3版本
添加这些依赖项
"@angular/fire":"^5.4.2",
"firebase": "^6.6.2",
"firebase-admin": "^8.9.2",
"fs-extra": "^9.0.1",
在package.json文件中并运行
npm安装
https://stackoverflow.com/questions/61735762
复制相似问题