The 'then' property does not exist in the 'void' type

How do I handle Typescript error:

Property 'then' does not exist on type 'void'

My code is as follows:

import {Component} from '@angular/core';
import {SocialSharing} from "ionic-native";

@Component({
  templateUrl: 'build/pages/about/about.html'
})
export class AboutPage {

  constructor() {

  }

  share() {
    SocialSharing.share('Take a look at our app. It is great! Download it from the App Store now.',
        'Take a look at our app. It is great! Download it from the App Store now.', null, null).then(
          res => {},
          err => {}
    );
  }

}
Run codeHide result
+2
source share
1 answer

The function definition sharereturns void, as you can also see in the error message

static share (message?: string, subject?: string, file?: string|Array<string>, url?: string): void {}

Therefore, you cannot call thenwhen calledshare

+1
source

Source: https://habr.com/ru/post/1652352/


All Articles