关于在webstrom开发uniapp使用promise报错的问题
记录一下uniapp在webstrom中开发,使用promise的时候报错的问题
报错代码
public query(param: any, queryFunc: Function) {
return new Promise((resolve, reject) => {
if (this._hasNextPage) {
resolve(queryFunc({
..._.pickBy(param),
page: {
page: this.page += 1,
pageSize: this.pageSize,
}
}))
} else {
reject()
}
})
}
报错的代码位置在return new Promise的时候会提示:
TS2585: 'Promise' only refers to a type, but is being used as a value here. Do you need to change your target library? Try changing the 'lib' compiler option to es2015 or later.
解决方案
安装es6-promise
npm i --save-dev @types/es6-promise
然后就OK了
这里贴一下原帖地址
关于在webstrom开发uniapp使用promise报错的问题
http://xuyuanhang.com//archives/guan-yu-zai-webstromkai-fa-uniappshi-yong-promisebao-cuo-de-wen-ti