"refers to a value, but is being used as a type here." Facebook 导入

"refers to a value, but is being used as a type here." Facebook import

所以我将 Facebook 登录添加到我的应用程序中,并且我遵循了 Ionic v4 的文档,

https://ionicframework.com/docs/v4/native/facebook/

并且在构造函数参数中从导入中添加 Facebook 项时出现错误。

import { Facebook, FacebookLoginResponse } from '@ionic-native/facebook/ngx';

constructor(private fb: Facebook) { }

private fb: Facebook 抛出 'Facebook' refers to a value, but is being used as a type here. Did you mean 'typeof Facebook'? 错误。

我确定这只是一个语法错误,但我不知道正确的语法。

从 TypeScript 3.8 开始,可以使用 Type-Only Imports。 要确保导入的参数不是值,而是类型,请执行以下操作:

import type { Facebook } from '@ionic-native/facebook/ngx';