简体   繁体   中英

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

So I was adding Facebook login into my app and I was following the documentation for Ionic v4,

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

and I was getting an error when adding the Facebook item from the import in the constructor parameters.

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

constructor(private fb: Facebook) { }

private fb: Facebook is throwing a 'Facebook' refers to a value, but is being used as a type here. Did you mean 'typeof Facebook'? 'Facebook' refers to a value, but is being used as a type here. Did you mean 'typeof Facebook'? error.

I'm sure it's just a syntax error, but I don't know the proper syntax.

As of TypeScript 3.8 it is possible to use Type-Only Imports . To make sure the imported parameter is not a value, but a type do this:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM