Search code examples
angularfacebookionic-frameworktypeof

"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'? error.

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


Solution

  • 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';