Skip to content

Commit

Permalink
Merge pull request #195 from toFrankie/master
Browse files Browse the repository at this point in the history
修复部分 API 因 JSDoc 注释错误导致 TS 类型检查不通过的问题
  • Loading branch information
jiajun-ifanr authored Nov 24, 2022
2 parents 778e489 + 6391094 commit e9cf0d6
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 8 deletions.
2 changes: 1 addition & 1 deletion core/Query.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class Query {
*
* @param {string} key - 用于查询判断的字段
* @param {string} operator - 判断操作符
* @param {string} value - 用于判断的值
* @param {any} value - 用于判断的值
* @returns {this} Query 实例
*/
compare(key, operator, value) {
Expand Down
2 changes: 1 addition & 1 deletion sdk-file/src/wechat/getWXACode.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const makeRealParams = (type, params, cdn, categoryName) => {
* @param {object} params 参数
* @param {boolean} [cdn] 是否上传二维码到文件存储并返回图片链接,默认为 false
* @param {string} [categoryName] 指定上传文件分类名,cdn 为 true 时有效,不指定该参数或分类名不存在,则默认上传到根目录
* @return {Promise<BaaS.Response<any>>}
* @return {Promise<BaaS.GetWXACodeResponse>}
*/
const getWXACode = (type, params, cdn, categoryName) => {
let realParams = makeRealParams(type, params, cdn, categoryName)
Expand Down
8 changes: 8 additions & 0 deletions sdk-file/src/wechat/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,11 @@
* @param {function} [getUserInfo] 获取用户信息 wx.getUserInfo
* @param {function} [requestPayment] 请求支付 wx.requestPayment
*/

/**
* @typedef GetWXACodeResponse
* @memberof BaaS
* @property {string} image 二维码的 base64 编码
* @property {string} [download_url] 请求参数 cdn=true 时返回,二维码的下载链接
* @property {object} [uploaded_file] 请求参数 cdn=true 时返回,图片文件对象。SDK >= 3.7.0 返回该参数
*/
10 changes: 10 additions & 0 deletions types/test/core/Query.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,28 @@ expectType<WebBaaS.Query>(wx.BaaS.Query.or(queryWeb, queryWeb))
*/
// wechat
expectType<WechatBaaS.Query>(queryWechat.compare('key', '=', 'test'))
expectType<WechatBaaS.Query>(queryWechat.compare('key', '=', true))
expectType<WechatBaaS.Query>(queryWechat.compare('key', '=', 1))

// qq
expectType<QqBaaS.Query>(queryQq.compare('key', '=', 'test'))
expectType<QqBaaS.Query>(queryQq.compare('key', '=', true))
expectType<QqBaaS.Query>(queryQq.compare('key', '=', 1))

// alipay
expectType<AlipayBaaS.Query>(queryAlipay.compare('key', '=', 'test'))
expectType<AlipayBaaS.Query>(queryAlipay.compare('key', '=', true))
expectType<AlipayBaaS.Query>(queryAlipay.compare('key', '=', 1))

// baidu
expectType<BaiduBaaS.Query>(queryBaidu.compare('key', '=', 'test'))
expectType<BaiduBaaS.Query>(queryBaidu.compare('key', '=', true))
expectType<BaiduBaaS.Query>(queryBaidu.compare('key', '=', 1))

// web
expectType<WebBaaS.Query>(queryWeb.compare('key', '=', 'test'))
expectType<WebBaaS.Query>(queryWeb.compare('key', '=', true))
expectType<WebBaaS.Query>(queryWeb.compare('key', '=', 1))



Expand Down
6 changes: 3 additions & 3 deletions types/test/web.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ expectType<Promise<WechatBaaS.Response<any>>>(wx.BaaS.getCensorResult(1))
/**
* getWXACode
*/
expectType<Promise<WechatBaaS.Response<any>>>(wx.BaaS.getWXACode('type', {}))
expectType<Promise<WechatBaaS.Response<any>>>(wx.BaaS.getWXACode('type', {}, true))
expectType<Promise<WechatBaaS.Response<any>>>(wx.BaaS.getWXACode('type', {}, true, 'category'))
expectType<Promise<WechatBaaS.GetWXACodeResponse>>(wx.BaaS.getWXACode('type', {}))
expectType<Promise<WechatBaaS.GetWXACodeResponse>>(wx.BaaS.getWXACode('type', {}, true))
expectType<Promise<WechatBaaS.GetWXACodeResponse>>(wx.BaaS.getWXACode('type', {}, true, 'category'))

/**
* pay
Expand Down
6 changes: 3 additions & 3 deletions types/test/wechat.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ expectType<Promise<WechatBaaS.Response<any>>>(wx.BaaS.getCensorResult(1))
/**
* getWXACode
*/
expectType<Promise<WechatBaaS.Response<any>>>(wx.BaaS.getWXACode('type', {}))
expectType<Promise<WechatBaaS.Response<any>>>(wx.BaaS.getWXACode('type', {}, true))
expectType<Promise<WechatBaaS.Response<any>>>(wx.BaaS.getWXACode('type', {}, true, 'category'))
expectType<Promise<WechatBaaS.GetWXACodeResponse>>(wx.BaaS.getWXACode('type', {}))
expectType<Promise<WechatBaaS.GetWXACodeResponse>>(wx.BaaS.getWXACode('type', {}, true))
expectType<Promise<WechatBaaS.GetWXACodeResponse>>(wx.BaaS.getWXACode('type', {}, true, 'category'))

/**
* pay
Expand Down

0 comments on commit e9cf0d6

Please sign in to comment.