wechat-miniprogram / wechat-miniprogram/api-typings
方法重载Overload for FirmwareManager.statSync and FirmwareManager.statSync
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 803
- Forks
- 117
- Avg merge
- 24m
- Merged PRs (30d)
- 1
Description
Problem 问题
从3.3.2升级至3.4.2时,代码中statSync部分报错,如:
When we upgrade from 3.3.2 to 3.4.2, code related to statSync throws error while build,
const fs = wx.getFileSystemManager();
const stat = fs.statSync('filePath');
return stat.isFile();
// ~~~~~~
// Error: Property 'isFile' does not exist on type 'Stats[]'.
Suggestions 建议
提供重载,方便已有代码推断正确类型。
Can you provide Overrides for automatic Type inference?
Examples FYI 示意
- statSync
interface FileSystemManager { statSync( path: string, recursive?: false ): Stats; statSync( path: string, recursive: true ): Stats[]; } - stat
interface FileSystemManager { stat(option: NonRecursiveStatOption): void stat(option: RecursiveStatOption): void } interface NonRecursiveStatOption { path: string complete?: StatCompleteCallback fail?: StatFailCallback recursive?: false success?: NonRecursiveStatSuccessCallback } interface RecursiveStatOption { path: string complete?: StatCompleteCallback fail?: StatFailCallback recursive: true success?: RecursiveStatSuccessCallback } interface NonRecursiveStatSuccessCallback { stats: Stats errMsg: string } interface RecursiveStatSuccessCallback { stats: Stats[] errMsg: string }
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 at the FileSystemManager declarations for statSync and stat, then compare the existing Stats and callback option types with the overloads shown in the issue. Confirm that non-recursive calls infer Stats, recursive calls infer Stats[], and the stat callback variants expose matching types by compiling the example usage.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 52/100