Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Typescript 财产';然后';不存在于类型';无效';_Typescript_Ionic2 - Fatal编程技术网

Typescript 财产';然后';不存在于类型';无效';

Typescript 财产';然后';不存在于类型';无效';,typescript,ionic2,Typescript,Ionic2,我应该如何处理Typescript错误: Property 'then' does not exist on type 'void' 我的代码如下所示: 从'@angular/core'导入{Component}; 从“离子本机”导入{SocialSharing}; @组成部分({ templateUrl:'build/pages/about/about.html' }) 出口类约页{ 构造函数(){ } 股份(){ SocialSharing.share('看看我们的应用程序。它很棒!现在

我应该如何处理Typescript错误:

Property 'then' does not exist on type 'void'
我的代码如下所示:

从'@angular/core'导入{Component};
从“离子本机”导入{SocialSharing};
@组成部分({
templateUrl:'build/pages/about/about.html'
})
出口类约页{
构造函数(){
}
股份(){
SocialSharing.share('看看我们的应用程序。它很棒!现在就从应用程序商店下载它。',
“看看我们的应用。它很棒!现在就从应用商店下载它。”,空,空)。然后(
res=>{},
错误=>{}
);
}

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

static share (message?: string, subject?: string, file?: string|Array<string>, url?: string): void {}
静态共享(消息?:字符串,主题?:字符串,文件?:字符串|数组,url?:字符串):void{}

因此,在调用
share

时,您不能调用
then
,根据ionic native的ionic 2文档,插件包装在承诺中,因此我认为“then”是正确的使用方法。你可能是对的,但是实现说明了一些不同的东西。这是对正在发生的事情的唯一解释。看看这里,我想包装的东西并不适用于所有函数。如果您检查示例
Geolocation.getCurrentPosition()的实现,那么…
您将看到方法
getCurrentPosition
实际上返回了一个承诺,而
share
不会发生这种情况。我想在github问一下,这可能是一个错误,非常感谢您澄清这一点。现在有道理了。我当时已经把它移走了。