wechat-miniprogram / wechat-miniprogram/api-typings
[Feature request] Update api generation
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 803
- Forks
- 117
- Avg merge
- 24m
- Merged PRs (30d)
- 1
Description
Ts 4.4 introduce a new flag --exactOptionalPropertyTypes, and it's already on stable channel.
See https://devblogs.microsoft.com/typescript/announcing-typescript-4-4/#exact-optional-property-types
With this option,
interface Person {
name: string,
age?: number | undefined;
}
and
interface Person {
name: string,
age?: number;
}
won't be the same.
Which means all the opitional option should be extra announced with | undefined if it could be. Other wise code like following will be regarded as an error with --exactOptionalPropertyTypes
E.g.: we can pass title: undefined to the following api
let title: string | undefined;
// somehow set title only in some condfitions
wx.showLoading({ title });
// 不能将类型“string | undefined”分配给类型“string”。
// 不能将类型“undefined”分配给类型“string”。ts(2322)
So we should generate the option to:
// before
interface ShowLoadingOption {
/** 提示的内容 */
title: string
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
complete?: ShowLoadingCompleteCallback
/** 接口调用失败的回调函数 */
fail?: ShowLoadingFailCallback
/** 是否显示透明蒙层,防止触摸穿透 */
mask?: boolean
/** 接口调用成功的回调函数 */
success?: ShowLoadingSuccessCallback
}
// after
interface ShowLoadingOption {
/** 提示的内容 */
title: string | undefined
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
complete?: ShowLoadingCompleteCallback | undefined
/** 接口调用失败的回调函数 */
fail?: ShowLoadingFailCallback | undefined
/** 是否显示透明蒙层,防止触摸穿透 */
mask?: boolean | undefined
/** 接口调用成功的回调函数 */
success?: ShowLoadingSuccessCallback | undefined
}
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
The issue names no files or tests. Start by locating the API generation entry point and the generated TypeScript interfaces, then inspect how optional properties are emitted. Done means generated optional fields explicitly include | undefined where needed and the output supports TypeScript's --exactOptionalPropertyTypes example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100