Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

支持 uni.promises.[api],增加官方的带有 TypeScript 类型定义的 Promise 化的 API #4084

Closed
ModyQyW opened this issue Dec 23, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@ModyQyW
Copy link

ModyQyW commented Dec 23, 2022

新功能描述

支持 uni.promises.[api],增加官方的带有 TypeScript 类型定义的 Promise 化的 API。

uni
  .promises
  .getLocation({ ... })
  .then((result) => { ... })
  .catch((error) => { ... })
  .finally(() => { ... })

现状及问题

目前,uni-app 提供了基于 success、fail、complete 的 API 及其类型定义。对于 Promise 化的 API,没有类型定义。

这降低了开发者的实际体验,迫使开发者只能选择基于 success、fail、complete 的 API,并容易陷入回调地狱中。

尝试方案

uni-promises

@ModyQyW ModyQyW added the enhancement New feature or request label Dec 23, 2022
@ModyQyW ModyQyW changed the title 支持 uni.promises,增加官方的带有 TypeScript 类型定义的 Promise 化的 API 支持 uni.promises.[api],增加官方的带有 TypeScript 类型定义的 Promise 化的 API Dec 23, 2022
@StrivingRabbit
Copy link
Collaborator

StrivingRabbit commented Feb 13, 2023

关于api 的 Promise 化类型提示。除 uni.request 有返回值同步的方法(即以 sync 结束)以 create 开头的方法以 manager 结束的方法返回 task 的 api 暂不处理外,其他可以升级 @dcloudio/types@3.3.0 试试看

@StrivingRabbit
Copy link
Collaborator

部分 api promise 化提示已支持,后续进度请跟踪 #3009 查看

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants