diff --git a/README.md b/README.md
index b8b965f..7cfec0c 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,15 @@
-# api-typings
+# Wechat MiniProgram API Typings
+
Type definitions for APIs of Wechat Mini Program in TypeScript
+
+## Install
+
+```
+npm install miniprogram-api-typings
+```
+
+or specify a base library version:
+
+```
+npm install miniprogram-api-typings@2.4.0
+```
\ No newline at end of file
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..6947ec7
--- /dev/null
+++ b/package.json
@@ -0,0 +1,15 @@
+{
+ "name": "miniprogram-api-typings",
+ "version": "2.4.0",
+ "description": "Type definitions for APIs of Wechat Mini Program in TypeScript",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/wechat-miniprogram/api-typings.git"
+ },
+ "author": "wechat-miniprogram",
+ "license": "MIT",
+ "bugs": {
+ "url": "https://github.com/wechat-miniprogram/api-typings/issues"
+ },
+ "homepage": "https://github.com/wechat-miniprogram/api-typings#readme"
+}
diff --git a/types/index.d.ts b/types/index.d.ts
new file mode 100644
index 0000000..a5e8a7c
--- /dev/null
+++ b/types/index.d.ts
@@ -0,0 +1 @@
+///
diff --git a/types/wx/index.d.ts b/types/wx/index.d.ts
new file mode 100644
index 0000000..d55472a
--- /dev/null
+++ b/types/wx/index.d.ts
@@ -0,0 +1,13 @@
+///
+///
+///
+
+declare type IAnyObject = Record
+
+declare type KVInfer = {
+ [K in keyof T]: T[K]
+}
+
+declare type Void = T | undefined | null
+type PartialOptional = Partial> & Pick>
+
diff --git a/types/wx/lib.wx.api.d.ts b/types/wx/lib.wx.api.d.ts
new file mode 100644
index 0000000..66106c8
--- /dev/null
+++ b/types/wx/lib.wx.api.d.ts
@@ -0,0 +1,12468 @@
+/*! *****************************************************************************
+Copyright (c) 2018 Tencent, Inc. All rights reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+***************************************************************************** */
+
+declare namespace wx {
+ interface AccessFailCallbackResult {
+ /** 错误信息
+ *
+ * 可选值:
+ * - 'fail no such file or directory ${path}': 文件/目录不存在; */
+ errMsg: string;
+ }
+ interface AccessOption {
+ /** 要判断是否存在的文件/目录路径 */
+ path: string;
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
+ complete?: AccessCompleteCallback;
+ /** 接口调用失败的回调函数 */
+ fail?: AccessFailCallback;
+ /** 接口调用成功的回调函数 */
+ success?: AccessSuccessCallback;
+ }
+ /** 帐号信息 */
+ interface AccountInfo {
+ /** 小程序帐号信息 */
+ miniProgram: MiniProgram;
+ /** 插件帐号信息(仅在插件中调用时包含这一项) */
+ plugin: Plugin;
+ }
+ interface AddCardOption {
+ /** 需要添加的卡券列表 */
+ cardList: AddCardRequestInfo;
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
+ complete?: AddCardCompleteCallback;
+ /** 接口调用失败的回调函数 */
+ fail?: AddCardFailCallback;
+ /** 接口调用成功的回调函数 */
+ success?: AddCardSuccessCallback;
+ }
+ /** 需要添加的卡券列表 */
+ interface AddCardRequestInfo {
+ /** 卡券的扩展参数。需进行 JSON 序列化为**字符串**传入 */
+ cardExt: CardExt;
+ /** 卡券 ID */
+ cardId: string;
+ }
+ /** 卡券添加结果列表 */
+ interface AddCardResponseInfo {
+ /** 卡券的扩展参数,结构请参考前文 */
+ cardExt: string;
+ /** 用户领取到卡券的 ID */
+ cardId: string;
+ /** 加密 code,为用户领取到卡券的code加密后的字符串,解密请参照:[code 解码接口](https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1499332673_Unm7V) */
+ code: string;
+ /** 是否成功 */
+ isSuccess: boolean;
+ }
+ interface AddCardSuccessCallbackResult {
+ /** 卡券添加结果列表 */
+ cardList: AddCardResponseInfo;
+ }
+ interface AddPhoneContactOption {
+ /** 名字 */
+ firstName: string;
+ /** 公司电话 */
+ hostNumber?: string;
+ /** 电子邮件 */
+ email?: string;
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
+ complete?: AddPhoneContactCompleteCallback;
+ /** 网站 */
+ url?: string;
+ /** 昵称 */
+ nickName?: string;
+ /** 工作地址国家 */
+ workAddressCountry?: string;
+ /** 中间名 */
+ middleName?: string;
+ /** 工作地址省份 */
+ workAddressState?: string;
+ /** 手机号 */
+ mobilePhoneNumber?: string;
+ /** 工作地址城市 */
+ workAddressCity?: string;
+ /** 联系地址国家 */
+ addressCountry?: string;
+ /** 工作地址街道 */
+ workAddressStreet?: string;
+ /** 联系地址城市 */
+ addressCity?: string;
+ /** 工作地址邮政编码 */
+ workAddressPostalCode?: string;
+ /** 联系地址邮政编码 */
+ addressPostalCode?: string;
+ /** 住宅传真 */
+ homeFaxNumber?: string;
+ /** 职位 */
+ title?: string;
+ /** 住宅电话 */
+ homePhoneNumber?: string;
+ /** 工作电话 */
+ workPhoneNumber?: string;
+ /** 住宅地址国家 */
+ homeAddressCountry?: string;
+ /** 姓氏 */
+ lastName?: string;
+ /** 住宅地址省份 */
+ homeAddressState?: string;
+ /** 微信号 */
+ weChatNumber?: string;
+ /** 住宅地址城市 */
+ homeAddressCity?: string;
+ /** 联系地址街道 */
+ addressStreet?: string;
+ /** 工作传真 */
+ workFaxNumber?: string;
+ /** 接口调用失败的回调函数 */
+ fail?: AddPhoneContactFailCallback;
+ /** 接口调用成功的回调函数 */
+ success?: AddPhoneContactSuccessCallback;
+ /** 住宅地址邮政编码 */
+ homeAddressPostalCode?: string;
+ /** 住宅地址街道 */
+ homeAddressStreet?: string;
+ /** 头像本地文件路径 */
+ photoFilePath?: string;
+ /** 公司 */
+ organization?: string;
+ /** 联系地址省份 */
+ addressState?: string;
+ /** 备注 */
+ remark?: string;
+ }
+ /** 动画效果 */
+ interface AnimationOption {
+ /** 动画变化方式
+ *
+ * 可选值:
+ * - 'linear': 动画从头到尾的速度是相同的;
+ * - 'easeIn': 动画以低速开始;
+ * - 'easeOut': 动画以低速结束;
+ * - 'easeInOut': 动画以低速开始和结束; */
+ timingFunc?: 'linear' | 'easeIn' | 'easeOut' | 'easeInOut';
+ /** 动画变化时间,单位 ms */
+ duration?: number;
+ }
+ interface AppendFileFailCallbackResult {
+ /** 错误信息
+ *
+ * 可选值:
+ * - 'fail no such file or directory, open ${filePath}': 指定的 filePath 文件不存在;
+ * - 'fail illegal operation on a directory, open "${filePath}" ': 指定的 filePath 是一个已经存在的目录;
+ * - 'fail permission denied, open ${dirPath}': 指定的 filePath 路径没有写权限;
+ * - 'fail sdcard not mounted ': 指定的 filePath 是一个已经存在的目录; */
+ errMsg: string;
+ }
+ interface AppendFileOption {
+ /** 要追加的文本或二进制数据 */
+ data: string | ArrayBuffer;
+ /** 要追加内容的文件路径 */
+ filePath: string;
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
+ complete?: AppendFileCompleteCallback;
+ /** 接口调用失败的回调函数 */
+ fail?: AppendFileFailCallback;
+ /** 接口调用成功的回调函数 */
+ success?: AppendFileSuccessCallback;
+ /** 指定写入文件的字符编码
+ *
+ * 可选值:
+ * - 'ascii': ;
+ * - 'base64': ;
+ * - 'binary': ;
+ * - 'hex': ;
+ * - 'ucs2/ucs-2/utf16le/utf-16le': 以小端序读取;
+ * - 'utf-8/utf8': ;
+ * - 'latin1': ; */
+ encoding?:
+ | 'ascii'
+ | 'base64'
+ | 'binary'
+ | 'hex'
+ | 'ucs2/ucs-2/utf16le/utf-16le'
+ | 'utf-8/utf8'
+ | 'latin1';
+ }
+ /** 用户授权设置信息 */
+ interface AuthSetting {
+ /** 是否授权摄像头 */
+ camera: boolean;
+ /** 是否授权保存到相册 wx.saveImageToPhotosAlbum, wx.saveVideoToPhotosAlbum */
+ writePhotosAlbum: boolean;
+ /** 是否授权录音功能,对应接口 wx.startRecord */
+ record: boolean;
+ /** 是否授权微信运动步数,对应接口 wx.getWeRunData */
+ werun: boolean;
+ /** 是否授权发票抬头,对应接口 wx.chooseInvoiceTitle */
+ invoiceTitle: boolean;
+ /** 是否授权通讯地址,对应接口 wx.chooseAddress */
+ address: boolean;
+ /** 是否授权地理位置,对应接口 wx.getLocation wx.chooseLocation */
+ userLocation: boolean;
+ /** 是否授权用户信息,对应接口 wx.getUserInfo */
+ userInfo: boolean;
+ }
+ interface AuthorizeOption {
+ /** 需要获取权限的 scope,详见 [scope 列表]((授权#scope-列表)) */
+ scope: string;
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
+ complete?: AuthorizeCompleteCallback;
+ /** 接口调用失败的回调函数 */
+ fail?: AuthorizeFailCallback;
+ /** 接口调用成功的回调函数 */
+ success?: AuthorizeSuccessCallback;
+ }
+ /** 设备服务列表 */
+ interface BLECharacteristic {
+ /** 该特征值支持的操作类型 */
+ properties: Properties;
+ /** 蓝牙设备特征值的 uuid */
+ uuid: string;
+ }
+ /** 设备服务列表 */
+ interface BLEService {
+ /** 该服务是否为主服务 */
+ isPrimary: boolean;
+ /** 蓝牙设备服务的 uuid */
+ uuid: string;
+ }
+ /** BackgroundAudioManager 实例,可通过 [wx.getBackgroundAudioManager]((wx.getBackgroundAudioManager)) 获取。
+*
+* **示例代码**
+*
+*
+* ```js
+const backgroundAudioManager = wx.getBackgroundAudioManager()
+
+backgroundAudioManager.title = '此时此刻'
+backgroundAudioManager.epname = '此时此刻'
+backgroundAudioManager.singer = '许巍'
+backgroundAudioManager.coverImgUrl = 'http://y.gtimg.cn/music/photo_new/T002R300x300M000003rsKF44GyaSk.jpg?max_age=2592000'
+// 设置了 src 之后会自动播放
+backgroundAudioManager.src = 'http://ws.stream.qqmusic.qq.com/M500001VfvsJ21xFqb.mp3?guid=ffffffff82def4af4b12b3cd9337d5e7&uin=346897220&vkey=6292F51E1E384E061FF02C31F716658E5C81F5594D561F2E88B854E81CAAB7806D5E4F103E55D33C16F3FAC506D1AB172DE8600B37E43FAD&fromtag=46'
+``` */
+ interface BackgroundAudioManager {
+ /** 音频已缓冲的时间,仅保证当前播放时间点到此时间点内容已缓冲。(只读) */
+ buffered: number;
+ /** 封面图 URL,用于做原生音频播放器背景图。原生音频播放器中的分享功能,分享出去的卡片配图及背景也将使用该图。 */
+ coverImgUrl: string;
+ /** 当前音频的播放位置(单位:s),只有在有合法 src 时返回。(只读) */
+ currentTime: number;
+ /** 当前音频的长度(单位:s),只有在有合法 src 时返回。(只读) */
+ duration: number;
+ /** 专辑名,原生音频播放器中的分享功能,分享出去的卡片简介,也将使用该值。 */
+ epname: string;
+ /** 当前是否暂停或停止。(只读) */
+ paused: boolean;
+ /** 音频协议。默认值为 'http',设置 'hls' 可以支持播放 HLS 协议的直播音频。
+ *
+ * 最低基础库: `1.9.94` */
+ protocol: string;
+ /** 歌手名,原生音频播放器中的分享功能,分享出去的卡片简介,也将使用该值。 */
+ singer: string;
+ /** 音频的数据源({% version('2.2.3') %} 开始支持云文件ID)。默认为空字符串,**当设置了新的 src 时,会自动开始播放**,目前支持的格式有 m4a, aac, mp3, wav。 */
+ src: string;
+ /** 音频开始播放的位置(单位:s)。 */
+ startTime: number;
+ /** 音频标题,用于原生音频播放器音频标题(必填)。原生音频播放器中的分享功能,分享出去的卡片标题,也将使用该值。 */
+ title: string;
+ /** 页面链接,原生音频播放器中的分享功能,分享出去的卡片简介,也将使用该值。 */
+ webUrl: string;
+ }
+ /** 搜索到的设备列表 */
+ interface BluetoothDeviceInfo {
+ /** 用于区分设备的 id */
+ deviceId: string;
+ /** 蓝牙设备名称,某些设备可能没有 */
+ name: string;
+ }
+ interface BoundingClientRectCallbackResult {
+ /** 节点的高度 */
+ height: number;
+ /** 节点的宽度 */
+ width: number;
+ /** 节点的下边界坐标 */
+ bottom: number;
+ /** 节点的上边界坐标 */
+ top: number;
+ /** 节点的右边界坐标 */
+ right: number;
+ /** 节点的左边界坐标 */
+ left: number;
+ /** 节点的 dataset */
+ dataset: object;
+ /** 节点的 ID */
+ id: string;
+ }
+ /** 目标边界 */
+ interface BoundingClientRectResult {
+ /** 下边界 */
+ bottom: number;
+ /** 上边界 */
+ top: number;
+ /** 右边界 */
+ right: number;
+ /** 左边界 */
+ left: number;
+ }
+ /** 新搜索到的设备列表 */
+ interface CallbackResultBlueToothDevice {
+ /** 当前蓝牙设备的信号强度 */
+ RSSI: number;
+ /** 当前蓝牙设备的广播数据段中的 ManufacturerData 数据段。 */
+ advertisData: ArrayBuffer;
+ /** 当前蓝牙设备的广播数据段中的 ServiceUUIDs 数据段 */
+ advertisServiceUUIDs: Array;
+ /** 用于区分设备的 id */
+ deviceId: string;
+ /** 当前蓝牙设备的广播数据段中的 LocalName 数据段 */
+ localName: string;
+ /** 蓝牙设备名称,某些设备可能没有 */
+ name: string;
+ /** 当前蓝牙设备的广播数据段中的 ServiceData 数据段 */
+ serviceData: ArrayBuffer;
+ }
+ interface CameraContextStartRecordOption {
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
+ complete?: CameraContextStartRecordCompleteCallback;
+ /** 接口调用失败的回调函数 */
+ fail?: CameraContextStartRecordFailCallback;
+ /** 接口调用成功的回调函数 */
+ success?: CameraContextStartRecordSuccessCallback;
+ /** 超过30s或页面 `onHide` 时会结束录像 */
+ timeoutCallback?: StartRecordTimeoutCallback;
+ }
+ /** canvas 组件的绘图上下文 */
+ interface CanvasContext {
+ /** 填充颜色。用法同 [CanvasContext.setFillStyle()]((CanvasContext.setFillStyle))。
+ *
+ * 最低基础库: `1.9.90` */
+ fillStyle: string;
+ /** 当前字体样式的属性。符合 [CSS font 语法](https://developer.mozilla.org/zh-CN/docs/Web/CSS/font) 的 DOMString 字符串,至少需要提供字体大小和字体族名。默认值为 10px sans-serif。
+ *
+ * 最低基础库: `1.9.90` */
+ font: string;
+ /** 全局画笔透明度。范围 0-1,0 表示完全透明,1 表示完全不透明。 */
+ globalAlpha: number;
+ /** 在绘制新形状时应用的合成操作的类型。目前安卓版本只适用于 `fill` 填充块的合成,用于 `stroke` 线段的合成效果都是 `source-over`。
+ *
+ * 目前支持的操作有
+ * - 安卓:xor, source-over, source-atop, destination-out, lighter, overlay, darken, lighten, hard-light
+ * - iOS:xor, source-over, source-atop, destination-over, destination-out, lighter, multiply, overlay, darken, lighten, color-dodge, color-burn, hard-light, soft-light, difference, exclusion, saturation, luminosity
+ *
+ * 最低基础库: `1.9.90` */
+ globalCompositeOperation: string;
+ /** 线条的端点样式。用法同 [CanvasContext.setLineCap()]((CanvasContext.setLineCap))。
+ *
+ * 最低基础库: `1.9.90` */
+ lineCap: number;
+ /** 虚线偏移量,初始值为0
+ *
+ * 最低基础库: `1.9.90` */
+ lineDashOffset: number;
+ /** 线条的交点样式。用法同 [CanvasContext.setLineJoin()]((CanvasContext.setLineJoin))。
+ *
+ * 最低基础库: `1.9.90` */
+ lineJoin: number;
+ /** 线条的宽度。用法同 [CanvasContext.setLineWidth()]((CanvasContext.setLineWidth))。
+ *
+ * 最低基础库: `1.9.90` */
+ lineWidth: number;
+ /** 最大斜接长度。用法同 [CanvasContext.setMiterLimit()]((CanvasContext.setMiterLimit))。
+ *
+ * 最低基础库: `1.9.90` */
+ miterLimit: number;
+ /** 阴影的模糊级别
+ *
+ * 最低基础库: `1.9.90` */
+ shadowBlur: number;
+ /** 阴影的颜色
+ *
+ * 最低基础库: `1.9.90` */
+ shadowColor: number;
+ /** 阴影相对于形状在水平方向的偏移
+ *
+ * 最低基础库: `1.9.90` */
+ shadowOffsetX: number;
+ /** 阴影相对于形状在竖直方向的偏移
+ *
+ * 最低基础库: `1.9.90` */
+ shadowOffsetY: number;
+ /** 边框颜色。用法同 [CanvasContext.setFillStyle()]((CanvasContext.setStrokeStyle))。
+ *
+ * 最低基础库: `1.9.90` */
+ strokeStyle: string;
+ }
+ interface CanvasGetImageDataOption {
+ /** 将要被提取的图像数据矩形区域的高度 */
+ height: number;
+ /** 将要被提取的图像数据矩形区域的宽度 */
+ width: number;
+ /** 将要被提取的图像数据矩形区域的左上角纵坐标 */
+ y: number;
+ /** 将要被提取的图像数据矩形区域的左上角横坐标 */
+ x: number;
+ /** 画布标识,传入 `