Skip to content

Commit 70f2dbd

Browse files
committed
feat: update baselib defs to 2.28.0
1 parent 746ae44 commit 70f2dbd

File tree

6 files changed

+732
-460
lines changed

6 files changed

+732
-460
lines changed

test/api-doc.test.ts

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -846,17 +846,6 @@ import { expectType } from 'tsd'
846846
})
847847
}
848848

849-
// Test case from `wx.getFileInfo`
850-
{
851-
wx.getFileInfo({
852-
filePath: '',
853-
success(res) {
854-
expectType<number>(res.size)
855-
expectType<string>(res.digest)
856-
},
857-
})
858-
}
859-
860849
// Test case from `wx.getHCEState`
861850
{
862851
wx.getHCEState({
@@ -927,24 +916,6 @@ import { expectType } from 'tsd'
927916
}
928917
}
929918

930-
// Test case from `wx.getSavedFileInfo`
931-
{
932-
wx.getSavedFileList({
933-
success(res) {
934-
res.fileList
935-
},
936-
})
937-
}
938-
939-
// Test case from `wx.getSavedFileList`
940-
{
941-
wx.getSavedFileList({
942-
success(res) {
943-
res.fileList
944-
},
945-
})
946-
}
947-
948919
// Test case from `wx.getSelectedTextRange`
949920
{
950921
wx.getSelectedTextRange({
@@ -1452,22 +1423,6 @@ type TPlatform = 'ios' | 'android' | 'windows' | 'mac' | 'devtools'
14521423
})
14531424
}
14541425

1455-
// Test case from `wx.removeSavedFile`
1456-
{
1457-
wx.getSavedFileList({
1458-
success(res) {
1459-
if (res.fileList.length > 0) {
1460-
wx.removeSavedFile({
1461-
filePath: res.fileList[0].filePath,
1462-
complete(res) {
1463-
console.log(res)
1464-
},
1465-
})
1466-
}
1467-
},
1468-
})
1469-
}
1470-
14711426
// Test case from `wx.removeStorageSync`
14721427
{
14731428
wx.removeStorage({
@@ -1542,21 +1497,6 @@ type TPlatform = 'ios' | 'android' | 'windows' | 'mac' | 'devtools'
15421497
})
15431498
}
15441499

1545-
// Test case from `wx.saveFile`
1546-
{
1547-
wx.chooseImage({
1548-
success(res) {
1549-
const tempFilePaths = res.tempFilePaths
1550-
wx.saveFile({
1551-
tempFilePath: tempFilePaths[0],
1552-
success(res) {
1553-
res.savedFilePath
1554-
},
1555-
})
1556-
},
1557-
})
1558-
}
1559-
15601500
// Test case from `wx.saveImageToPhotosAlbum`
15611501
{
15621502
wx.saveImageToPhotosAlbum({

test/api-promisify.test.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,6 @@ wx.saveVideoToPhotosAlbum({
6363
expectType<WechatMiniprogram.GeneralCallbackResult>(res)
6464
},
6565
})
66-
wx.removeSavedFile({
67-
filePath: '',
68-
success(res) {
69-
expectType<WechatMiniprogram.GeneralCallbackResult>(res)
70-
},
71-
})
7266

7367
wx.createBLEConnection({
7468
deviceId: '',
@@ -139,9 +133,6 @@ wx.previewImage({ urls: [] }).then(res => {
139133
wx.saveVideoToPhotosAlbum({ filePath: '' }).then(res => {
140134
expectType<WechatMiniprogram.GeneralCallbackResult>(res)
141135
})
142-
wx.removeSavedFile({ filePath: '' }).then(res => {
143-
expectType<WechatMiniprogram.GeneralCallbackResult>(res)
144-
})
145136
wx.createBLEConnection({ deviceId: '' }).then(res => {
146137
expectType<WechatMiniprogram.BluetoothError>(res)
147138
})
@@ -193,9 +184,6 @@ async () => {
193184
expectType<WechatMiniprogram.GeneralCallbackResult>(
194185
await wx.saveVideoToPhotosAlbum({ filePath: '' }),
195186
)
196-
expectType<WechatMiniprogram.GeneralCallbackResult>(
197-
await wx.removeSavedFile({ filePath: '' }),
198-
)
199187
expectType<WechatMiniprogram.BluetoothError>(
200188
await wx.createBLEConnection({ deviceId: '' }),
201189
)

test/issue.test.ts

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -277,16 +277,16 @@ import WX = WechatMiniprogram
277277
// https://github.com/wechat-miniprogram/api-typings/issues/133
278278
{
279279
type IData = {
280-
name: string,
280+
name: string
281281
}
282282
type IProperty = {
283-
id: typeof Number,
283+
id: typeof Number
284284
}
285285
type IMethod = {
286-
setJob(job: string): void,
286+
setJob(job: string): void
287287
}
288288
type ICustomInstanceProperty = {
289-
job: string,
289+
job: string
290290
}
291291
Component<IData, IProperty, IMethod, ICustomInstanceProperty>({
292292
properties: {
@@ -364,14 +364,7 @@ import WX = WechatMiniprogram
364364
}
365365

366366
// https://github.com/wechat-miniprogram/api-typings/issues/157
367-
{
368-
wx.saveFile({
369-
tempFilePath: '',
370-
success(res) {
371-
expectType<string>(res.savedFilePath)
372-
}
373-
})
374-
}
367+
// Test case for #157 is removed since `wx.saveFile` is no longer supported
375368

376369
// https://github.com/wechat-miniprogram/api-typings/issues/159
377370
{
@@ -426,7 +419,7 @@ import WX = WechatMiniprogram
426419
expectType<string>(res.whatever)
427420
expectType<string>(res.randomTemplateId)
428421
},
429-
});
422+
})
430423
}
431424

432425
// https://github.com/wechat-miniprogram/api-typings/issues/204

types/wx/index.d.ts

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,21 +67,49 @@ declare namespace WechatMiniprogram {
6767
type AudioListener = any
6868
type WebGLTexture = any
6969
type WebGLRenderingContext = any
70+
71+
// TODO: fill worklet type
72+
type WorkletFunction = (...args: any) => any
73+
type AnimationObject = any
74+
type SharedValue = any
75+
type DerivedValue = any
7076
}
7177

7278
declare let console: WechatMiniprogram.Console
7379

7480
declare let wx: WechatMiniprogram.Wx
7581
/** 引入模块。返回模块通过 `module.exports` 或 `exports` 暴露的接口。 */
76-
declare function require(
77-
/** 需要引入模块文件相对于当前文件的相对路径,或 npm 模块名,或 npm 模块路径。不支持绝对路径 */
78-
module: string
79-
): any
82+
interface Require {
83+
(
84+
/** 需要引入模块文件相对于当前文件的相对路径,或 npm 模块名,或 npm 模块路径。不支持绝对路径 */
85+
module: string,
86+
/** 用于异步获取其他分包中的模块的引用结果,详见 [分包异步化]((subpackages/async)) */
87+
callback?: (moduleExport: any) => void,
88+
/** 异步获取分包失败时的回调,详见 [分包异步化]((subpackages/async)) */
89+
errorCallback?: (err: any) => void
90+
): any
91+
/** 以 Promise 形式异步引入模块。返回模块通过 `module.exports` 或 `exports` 暴露的接口。 */
92+
async(
93+
/** 需要引入模块文件相对于当前文件的相对路径,或 npm 模块名,或 npm 模块路径。不支持绝对路径 */
94+
module: string
95+
): Promise<any>
96+
}
97+
declare const require: Require
8098
/** 引入插件。返回插件通过 `main` 暴露的接口。 */
81-
declare function requirePlugin(
82-
/** 需要引入的插件的 alias */
83-
module: string
84-
): any
99+
interface RequirePlugin {
100+
(
101+
/** 需要引入的插件的 alias */
102+
module: string,
103+
/** 用于异步获取其他分包中的插件的引用结果,详见 [分包异步化]((subpackages/async)) */
104+
callback?: (pluginExport: any) => void
105+
): any
106+
/** 以 Promise 形式异步引入插件。返回插件通过 `main` 暴露的接口。 */
107+
async(
108+
/** 需要引入的插件的 alias */
109+
module: string
110+
): Promise<any>
111+
}
112+
declare const requirePlugin: RequirePlugin
85113
/** 插件引入当前使用者小程序。返回使用者小程序通过 [插件配置中 `export` 暴露的接口](https://developers.weixin.qq.com/miniprogram/dev/framework/plugin/using.html#%E5%AF%BC%E5%87%BA%E5%88%B0%E6%8F%92%E4%BB%B6)。
86114
*
87115
* 该接口只在插件中存在

0 commit comments

Comments
 (0)