wechat-miniprogram / api-typings

Type definitions for APIs of Wechat Mini Program in TypeScript
MIT License
743 stars 112 forks source link

wx.onNeedPrivacyAuthorization方法的参数类型错误 #309

Open taodaran opened 1 year ago

taodaran commented 1 year ago

正确的类型应该是一个resolve和一个info,然而实际上是{errMsg:string}

xucr11 commented 1 year ago

正确的类型应该是一个resolve和一个info,然而实际上是{errMsg:string}

你再看仔细点?

wsli10 commented 1 year ago

正确的类型应该是一个resolve和一个info,然而实际上是{errMsg:string}

你再看仔细点?

@xucr11

https://github.com/wechat-miniprogram/api-typings/blob/master/types/wx/lib.wx.api.d.ts#L25493-L25496

onNeedPrivacyAuthorization(
    /** 隐私接口需要用户授权事件的监听函数 */
    listener: OnNeedPrivacyAuthorizationCallback
): void

https://github.com/wechat-miniprogram/api-typings/blob/master/types/wx/lib.wx.api.d.ts#L30422-L30424

type OnNeedPrivacyAuthorizationCallback = (
    res: GeneralCallbackResult
) => void

https://github.com/wechat-miniprogram/api-typings/blob/master/types/wx/lib.wx.api.d.ts#L4965C2-L4968C6


interface GeneralCallbackResult {
    /** 错误信息 */
    errMsg: string
}

image

JourneyL commented 1 year ago

@wsli10 有临时解决方案吗

wsli10 commented 1 year ago

@wsli10 有临时解决方案吗

@JourneyL 现在隐私弹窗不写也行,微信会有官方的弹窗😓

如果需要自定义弹窗,还必须用TS,那就直接 as unknown as XXX

type Resolve = (resolveOptions: {
  event: 'agree' | 'disagree' | 'exposureAuthorization';
  buttonId?: string;
}) => void

wx.onNeedPrivacyAuthorization(resolve => {
  (resolve as unknown as Resolve)(...)
})
JourneyL commented 12 months ago

@wsli10 好的谢谢大佬