属性"then"在类型"void"上不存在 [英] Property 'then' does not exist on type 'void'

查看:522
本文介绍了属性"then"在类型"void"上不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我应该如何处理Typescript错误:

How should I handle the Typescript error:

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

我的代码如下:

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 => {}
    );
  }

}

推荐答案

函数share的定义返回void,您也可以在错误消息中看到

The definition of the function share returns void as you can also see in the error message

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

因此,调用share

这篇关于属性"then"在类型"void"上不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆