In my Ionic/Angular project I am using SocialSharing-PhoneGap-Plugin. It has included type definitions and when I work with it in vscode I see how them are recognized.
The problem I have if that the angular compiler does not find them. For example, using:
window.plugins.socialsharing.shareViaEmail();
will throw an error:
Property 'plugins' does not exist on type 'Window'.
If I try to map it like
const socialsharing: SocialSharing = (window as any).plugins.socialsharing;
I get
Cannot find name 'SocialSharing'.
How can I let Angular/Ionic know those types (that live in node_modules/cordova-plugin-x-socialsharing/types/index.d.ts
) ?
To the solution was to add new file in my src
folder with a triple slash reference to the types file
typings.d.ts
/// <reference path="../node_modules/cordova-plugin-x-socialsharing/types/index.d.ts" />
Now it works!