Skip to content

Commit 006bfe2

Browse files
committed
fix: type fix
1 parent 36f991f commit 006bfe2

File tree

2 files changed

+55
-100
lines changed

2 files changed

+55
-100
lines changed

test/api-doc.test.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { expectType } from 'tsd'
2-
2+
type TPlatform = 'ios' | 'android' | 'windows' | 'mac'
33
// Test case from `Animation`
44
{
55
Page({
@@ -1034,7 +1034,7 @@ import { expectType } from 'tsd'
10341034
expectType<number>(res.windowHeight)
10351035
expectType<string>(res.language)
10361036
expectType<string>(res.version)
1037-
expectType<string>(res.platform)
1037+
expectType<TPlatform>(res.platform)
10381038
},
10391039
})
10401040
}
@@ -1049,7 +1049,7 @@ import { expectType } from 'tsd'
10491049
expectType<number>(res.windowHeight)
10501050
expectType<string>(res.language)
10511051
expectType<string>(res.version)
1052-
expectType<string>(res.platform)
1052+
expectType<TPlatform>(res.platform)
10531053
},
10541054
})
10551055
}
@@ -1064,7 +1064,7 @@ import { expectType } from 'tsd'
10641064
expectType<number>(res.windowHeight)
10651065
expectType<string>(res.language)
10661066
expectType<string>(res.version)
1067-
expectType<string>(res.platform)
1067+
expectType<TPlatform>(res.platform)
10681068
}
10691069
})
10701070
}
@@ -2167,7 +2167,7 @@ import { expectType } from 'tsd'
21672167
expectType<number>(res.windowHeight)
21682168
expectType<string>(res.language)
21692169
expectType<string>(res.version)
2170-
expectType<string>(res.platform)
2170+
expectType<TPlatform>(res.platform)
21712171
} catch (e) {
21722172
// Do something when catch error
21732173
}
@@ -2183,7 +2183,7 @@ import { expectType } from 'tsd'
21832183
expectType<number>(res.windowHeight)
21842184
expectType<string>(res.language)
21852185
expectType<string>(res.version)
2186-
expectType<string>(res.platform)
2186+
expectType<TPlatform>(res.platform)
21872187
} catch (e) {
21882188
// Do something when catch error
21892189
}
@@ -3226,6 +3226,8 @@ import { expectType } from 'tsd'
32263226
const observer = performance.createObserver(entryList => {
32273227
console.log(entryList.getEntries())
32283228
})
3229+
// FIXME
3230+
// @ts-ignore
32293231
observer.observe({ entryTypes: ['render', 'script', 'navigation'] })
32303232
}
32313233

types/wx/lib.wx.api.d.ts

Lines changed: 47 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -3336,7 +3336,7 @@ backgroundAudioManager.src = 'http://ws.stream.qqmusic.qq.com/M500001VfvsJ21xFqb
33363336
/** 需要基础库: `2.22.1`
33373337
*
33383338
* 目前 toast 和 loading 相关接口可以相互混用,此参数可用于取消混用特性 */
3339-
noConflict?: number
3339+
noConflict?: boolean
33403340
/** 接口调用成功的回调函数 */
33413341
success?: HideLoadingSuccessCallback
33423342
}
@@ -7891,18 +7891,18 @@ wx.getSetting({
78917891
interface VKConfig {
78927892
/** 跟踪配置 */
78937893
track: Track
7894+
/** 需要基础库: `2.23.0`
7895+
*
7896+
* 绑定的 WebGLRenderingContext 对象 */
7897+
gl?: WebGLRenderingContext
78947898
/** 需要基础库: `2.22.0`
78957899
*
78967900
* vision kit 版本,目前只有 iOS 基础库 2.22.0 以上支持 v2
78977901
*
78987902
* 可选值:
78997903
* - 'v1': 旧版本;
79007904
* - 'v2': v2 版本,目前只有 iOS 基础库 2.22.0 以上支持; */
7901-
version: 'v1' | 'v2'
7902-
/** 需要基础库: `2.23.0`
7903-
*
7904-
* 绑定的 WebGLRenderingContext 对象 */
7905-
gl?: WebGLRenderingContext
7905+
version?: 'v1' | 'v2'
79067906
}
79077907
/** 需要基础库: `2.20.0`
79087908
*
@@ -8160,18 +8160,18 @@ worker.terminate()
81608160
serviceId: string
81618161
/** 蓝牙设备特征对应的二进制值 */
81628162
value: ArrayBuffer
8163-
/** 蓝牙特征值的写模式设置,有两种模式,iOS 优先 write,安卓优先 writeNoResponse 。
8164-
*
8165-
* 可选值:
8166-
* - 'write': 强制回复写,不支持时报错;
8167-
* - 'writeNoResponse': 强制无回复写,不支持时报错; */
8168-
writeType: 'write' | 'writeNoResponse'
81698163
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
81708164
complete?: WriteBLECharacteristicValueCompleteCallback
81718165
/** 接口调用失败的回调函数 */
81728166
fail?: WriteBLECharacteristicValueFailCallback
81738167
/** 接口调用成功的回调函数 */
81748168
success?: WriteBLECharacteristicValueSuccessCallback
8169+
/** 蓝牙特征值的写模式设置,有两种模式,iOS 优先 write,安卓优先 writeNoResponse 。
8170+
*
8171+
* 可选值:
8172+
* - 'write': 强制回复写,不支持时报错;
8173+
* - 'writeNoResponse': 强制无回复写,不支持时报错; */
8174+
writeType?: 'write' | 'writeNoResponse'
81758175
}
81768176
interface WriteCharacteristicValueObject {
81778177
/** 蓝牙特征的 UUID */
@@ -9174,7 +9174,7 @@ worker.terminate()
91749174
* 批量添加规则,规则写法可参考 [CacheManager.addRule](https://developers.weixin.qq.com/miniprogram/dev/api/storage/cachemanager/CacheManager.addRule.html)。 */
91759175
addRules(
91769176
/** 规则列表 */
9177-
rules: Array<string | RegExp | Object>
9177+
rules: Array<string | RegExp | IAnyObject>
91789178
): string[]
91799179
/** [CacheManager.clearCaches()](https://developers.weixin.qq.com/miniprogram/dev/api/storage/cachemanager/CacheManager.clearCaches.html)
91809180
*
@@ -17440,11 +17440,11 @@ wx.chooseImage({
1744017440
*
1744117441
* **示例代码**
1744217442
*
17443-
* v2 版本:[在微信开发者工具中查看示例](https://developers.weixin.qq.com/s/RyunNnmp7Mwx)
17443+
* v2 版本:[在微信开发者工具中查看示例](https://developers.weixin.qq.com/s/E2okP7mB7Vyr)
1744417444
*
1744517445
*
1744617446
*
17447-
* v1 版本:[在微信开发者工具中查看示例](https://developers.weixin.qq.com/s/NYZcIJmZ7cvJ)
17447+
* v1 版本:[在微信开发者工具中查看示例](https://developers.weixin.qq.com/s/cCzLqZmm7FxD)
1744817448
* ```js
1744917449
// 以下 demo 以 v2 为例
1745017450
// 创建 session 对象
@@ -17556,10 +17556,10 @@ try {
1755617556
// Do something when catch error
1755717557
}
1755817558
``` */
17559-
getStorageSync(
17559+
getStorageSync<T = any>(
1756017560
/** 本地缓存中指定的 key */
1756117561
key: string
17562-
): any
17562+
): T
1756317563
/** [boolean wx.canIUse(string schema)](https://developers.weixin.qq.com/miniprogram/dev/api/base/wx.canIUse.html)
1756417564
*
1756517565
* 需要基础库: `1.1.1`
@@ -17958,9 +17958,6 @@ wx.checkSession({
1795817958
* 在插件中使用:需要基础库 `2.16.1`
1795917959
*
1796017960
* 获取用户收货地址。调起用户编辑收货地址原生界面,并在编辑完成后返回用户选择的地址。
17961-
* ## 申请开通
17962-
* 暂只针对国内主体且具备使用收货地址场景的小程序开放,在小程序管理后台,「开发」-「开发管理」-「接口设置」中自助开通该接口权限。
17963-
* 接口权限申请入口将于2022年3月11日开始内测,于3月31日全量上线。并从4月18日开始,在代码审核环节将检测该接口是否已完成开通,如未开通,将在代码提审环节进行拦截。
1796417961
*
1796517962
* **示例代码**
1796617963
*
@@ -18066,9 +18063,6 @@ wx.chooseInvoiceTitle({
1806618063
* 在插件中使用:需要基础库 `1.9.6`
1806718064
*
1806818065
* 打开地图选择位置。
18069-
* ## 申请开通
18070-
* 暂只针对国内主体且具备与地理位置强相关的使用场景的小程序开放,在小程序管理后台,「开发」-「开发管理」-「接口设置」中自助开通该接口权限。
18071-
* 接口权限申请入口将于2022年3月11日开始内测,于3月31日全量上线。并从4月18日开始,在代码审核环节将检测该接口是否已完成开通,如未开通,将在代码提审环节进行拦截。
1807218066
*
1807318067
* **示例**
1807418068
*
@@ -18132,9 +18126,6 @@ wx.chooseMessageFile({
1813218126
* 在插件中使用:不支持
1813318127
*
1813418128
* 打开POI列表选择位置,支持模糊定位(精确到市)和精确定位混选。
18135-
* ## 申请开通
18136-
* 暂只针对国内主体且具备与地理位置强相关的使用场景的小程序开放,在小程序管理后台,「开发」-「开发管理」-「接口设置」中自助开通该接口权限。
18137-
* 接口权限申请入口将于2022年3月11日开始内测,于3月31日全量上线。并从4月18日开始,在代码审核环节将检测该接口是否已完成开通,如未开通,将在代码提审环节进行拦截。
1813818129
*
1813918130
* **示例**
1814018131
*
@@ -18939,26 +18930,7 @@ wx.getLocalIPAddress({
1893918930
*
1894018931
* 在插件中使用:需要基础库 `1.9.6`
1894118932
*
18942-
* 获取当前的地理位置、速度。当用户离开小程序后,此接口无法调用。开启高精度定位,接口耗时会增加,可指定 highAccuracyExpireTime 作为超时时间。地图相关使用的坐标格式应为 gcj02。
18943-
* 高频率调用会导致耗电,如有需要可使用持续定位接口 `wx.onLocationChange`。
18944-
* 基础库 `2.17.0` 版本起 `wx.getLocation` 增加调用频率限制,[相关公告](https://developers.weixin.qq.com/community/develop/doc/000aee91a98d206bc6dbe722b51801)。
18945-
*
18946-
* ## 申请开通
18947-
* 暂只针对国内主体如下类目的小程序开放,需要先通过类目审核,再在小程序管理后台,「开发」-「开发管理」-「接口设置」中自助开通该接口权限。
18948-
* 接口权限申请入口将于2022年3月11日开始内测,于3月31日全量上线。并从4月18日开始,在代码审核环节将检测该接口是否已完成开通,如未开通,将在代码提审环节进行拦截。
18949-
*
18950-
* | 一级类目/主体类型 | 二级类目 | 应用场景 |
18951-
* | -------------- | -------| -------- |
18952-
* | 电商平台 | / | 售卖商品发货、收货服务 |
18953-
* | 商家自营 | / | 售卖商品发货、收货服务 |
18954-
* | 医疗服务 | 公立医疗机构、三级私立医疗机构、其他私立医疗机构、就医服务、其他医学健康服务、药品(非处方药)销售、非处方药销售平台、医疗器械生产企业、医疗器械自营、医疗器械经营销售平台、互联网医院血液、干细胞服务、临床试验 | 1、实际物品/药品接收服务 2、附近医院查询服务 |
18955-
* | 交通服务 | / | 代驾服务、租车网点查询、附近车辆查询等相关服务 |
18956-
* | 生活服务 | / | 上门服务作业等线下场景 |
18957-
* | 物流服务 | 收件/派件、查件、邮政、装卸搬运、快递柜、货物运输 | 快递/货物收发服务 |
18958-
* | 餐饮服务 | 点餐平台、外卖平台 | 线下送餐服务 |
18959-
* | 工具 | 天气、信息查询 | 与地理位置相关的服务,比如潮汐查询、海拔查询、天气查询等 |
18960-
* | 政务民生 | / | 提供政务单位相关业务 |
18961-
* | 政府主体帐号 | / | 提供政务单位相关业务 |
18933+
* 获取当前的地理位置、速度。当用户离开小程序后,此接口无法调用。开启高精度定位,接口耗时会增加,可指定 highAccuracyExpireTime 作为超时时间。地图相关使用的坐标格式应为 gcj02。高频率调用会导致耗电,如有需要可使用持续定位接口 `wx.onLocationChange`。基础库 `2.17.0` 版本起 `wx.getLocation` 增加调用频率限制,[相关公告](https://developers.weixin.qq.com/community/develop/doc/000aee91a98d206bc6dbe722b51801)。
1896218934
*
1896318935
* **示例代码**
1896418936
*
@@ -19596,7 +19568,7 @@ wx.hideKeyboard({
1959619568
*
1959719569
* 隐藏 loading 提示框 */
1959819570
hideLoading<T extends HideLoadingOption = HideLoadingOption>(
19599-
option: T
19571+
option?: T
1960019572
): PromisifySuccessResult<T, HideLoadingOption>
1960119573
/** [wx.hideNavigationBarLoading(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/ui/navigation-bar/wx.hideNavigationBarLoading.html)
1960219574
*
@@ -20908,23 +20880,6 @@ wx.onKeyboardHeightChange(res => {
2090820880
*
2090920881
* 监听实时地理位置变化事件,需结合 [wx.startLocationUpdateBackground](https://developers.weixin.qq.com/miniprogram/dev/api/location/wx.startLocationUpdateBackground.html)、[wx.startLocationUpdate](https://developers.weixin.qq.com/miniprogram/dev/api/location/wx.startLocationUpdate.html)使用。
2091020882
*
20911-
* ## 申请开通
20912-
* 暂只针对国内主体如下类目的小程序开放,需要先通过类目审核,再在小程序管理后台,「开发」-「开发管理」-「接口设置」中自助开通该接口权限。
20913-
* 接口权限申请入口将于2022年3月11日开始内测,于3月31日全量上线。并从4月18日开始,在代码审核环节将检测该接口是否已完成开通,如未开通,将在代码提审环节进行拦截。
20914-
*
20915-
* | 一级类目/主体类型 | 二级类目 | 应用场景 |
20916-
* | -------------- | -------| -------- |
20917-
* | 电商平台 | / | 售卖商品发货、收货服务 |
20918-
* | 商家自营 | / | 售卖商品发货、收货服务 |
20919-
* | 医疗服务 | 公立医疗机构、三级私立医疗机构、其他私立医疗机构、就医服务、其他医学健康服务、药品(非处方药)销售、非处方药销售平台、医疗器械生产企业、医疗器械自营、医疗器械经营销售平台、互联网医院血液、干细胞服务、临床试验 | 1、实际物品/药品接收服务 2、附近医院查询服务 |
20920-
* | 交通服务 | / | 代驾服务、租车网点查询、附近车辆查询等相关服务 |
20921-
* | 生活服务 | / | 上门服务作业等线下场景 |
20922-
* | 物流服务 | 收件/派件、查件、邮政、装卸搬运、快递柜、货物运输 | 快递/货物收发服务 |
20923-
* | 餐饮服务 | 点餐平台、外卖平台 | 线下送餐服务 |
20924-
* | 工具 | 天气、信息查询 | 与地理位置相关的服务,比如潮汐查询、海拔查询、天气查询等 |
20925-
* | 政务民生 | / | 提供政务单位相关业务 |
20926-
* | 政府主体帐号 | / | 提供政务单位相关业务 |
20927-
*
2092820883
* **示例代码**
2092920884
*
2093020885
* ```js
@@ -21554,35 +21509,33 @@ wx.startRecord({
2155421509
* __该接口仅在小程序插件中可调用__,调用接口获得插件用户标志凭证(code)。插件可以此凭证换取用于识别用户的标识 openpid。用户不同、宿主小程序不同或插件不同的情况下,该标识均不相同,即当且仅当同一个用户在同一个宿主小程序中使用同一个插件时,openpid 才会相同。 */
2155521510
pluginLogin(args?: PluginLoginOption): void
2155621511
/** [wx.preloadAssets()](https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/wx.preloadAssets.html)
21557-
*
21558-
* 需要基础库: `2.22.1`
21559-
*
21560-
* 在插件中使用:不支持
21561-
*
21562-
* 为视图层预加载媒体资源文件, 目前支持:font,image
21563-
*
21564-
* **示例代码**
21565-
*
21566-
* ```js
21567-
wx.preloadAssets({
21568-
data: [
21569-
{
21570-
type: 'image',
21571-
src: imgUrl,
21572-
},
21573-
],
21574-
success(resp) {
21575-
console.log('preloadAssets success', resp)
21576-
},
21577-
fail(err) {
21578-
console.log('preloadAssets fail', err)
21579-
},
21580-
})
21581-
```
21582-
*
21583-
* ****
21584-
*
21585-
* - 开发过程中,可在开发者工具network面板查看预加载情况。 */
21512+
*
21513+
* 需要基础库: `2.22.1`
21514+
*
21515+
* 在插件中使用:不支持
21516+
*
21517+
* 为视图层预加载媒体资源文件, 目前支持:font,image
21518+
*
21519+
* **示例代码**
21520+
*
21521+
* wx.preloadAssets({
21522+
* data: [
21523+
* {
21524+
* type: 'image',
21525+
* src: imgUrl,
21526+
* },
21527+
* ],
21528+
* success(resp) {
21529+
* console.log('preloadAssets success', resp)
21530+
* },
21531+
* fail(err) {
21532+
* console.log('preloadAssets fail', err)
21533+
* },
21534+
* })
21535+
*
21536+
* ****
21537+
*
21538+
* - 开发过程中,可在开发者工具network面板查看预加载情况。 */
2158621539
preloadAssets(): void
2158721540
/** [wx.preloadWebview(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/wx.preloadWebview.html)
2158821541
*
@@ -21908,7 +21861,7 @@ wx.reportPerformance(1101, 680, 'custom')
2190821861
* 在插件中使用:不支持
2190921862
*
2191021863
* 创建自定义版交易组件订单,并发起支付。
21911-
* 仅接入了[自定义版交易组件](https://developers.weixin.qq.com/miniprogram/dev/framework/ministore/minishopopencomponent2/Introduction2)的小程序需要使用,普通小程序可直接使用 [`wx.requestPayment`](https://developers.weixin.qq.com/miniprogram/dev/api/payment/wx.requestPayment.html)。
21864+
* 仅接入了[自定义版交易组件](https://developers.weixin.qq.com/miniprogram/dev/framework/ministore/minishopopencomponent2/Introduction2)的小程序需要使用,普通小程序可直接使用 [`wx.requestPayment`](./wx.requestPayment)。
2191221865
*
2191321866
* **前置检查**
2191421867
*

0 commit comments

Comments
 (0)