wechat-miniprogram / wechat-miniprogram/api-typings
Feature Request: 代码模块化
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 803
- Forks
- 117
- Avg merge
- 24m
- Merged PRs (30d)
- 1
Description
在微信小程序中,我们把类型和类型的全局变量放到了一个文件里。
而在支付宝小程序中:
- 类型声明在 @mini-types/my 这个包。
- 全局变量在 @mini-types/global 这个包。
- @mini-types/alipay 导出了上面两个包
https://github.com/ant-mini-program/api-typings/tree/main/packages
模块化之后,对于跨平台的小程序库的开发,将会有极大帮助。因为库作者可以从 @mini-types/my 导入类型,而不导入类似 @mini-types/global 这样的全局变量,不会出现全局变量冲突。
现在 uniapp,支付宝小程序,微信小程序,都导出了 Page,App 等全局变量,很容易冲突。作为库的作者,希望不导入其中的任何一个全局变量。但是为了能走其类型检查,则希望导入类型。
另外,如果 A 库用了 @types/wechat-miniprogram,B 库用了 miniprogram-api-typings。则他们也会出现类型冲突。如果把代码模块化后,这个问题也会被解决。
请问一下,微信小程序也能支持类型模块化吗?
如果有兴趣的话,我可以一起参与改造。
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading types/wx/lib.wx.page.d.ts around line 254, then compare the modular package layout in the referenced ant-mini-program/api-typings packages. Done means separating WeChat type declarations from global variables so libraries can import types without global-variable or cross-package conflicts.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- developer-experience
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100