“CredentialType”类型上不存在 Web OTP API 属性“代码”

问题描述

我正在尝试实施 Web OTP API Typescript Typings issue - Missing Types in TypeScript 中描述的解决方案,但出现以下错误

     Property 'code' does not exist on type 'CredentialType'.

有人可以帮助我理解并解决这个问题吗?

示例:

async otpRequest() {
    if ('OTPCredential' in window) {

      const abortController = new AbortController();
      let timer = setTimeout(() => {
        abortController.abort();
      },10 * 1000);

      let o: CredentialRequestOptions = {
        otp: { transport: ['sms'] },signal: abortController.signal
      };

      const content = await navigator['credentials'].get(o);

      // here: Property 'code' does not exist on type 'CredentialType'
      console.log(content.code)
      
      }).catch(err => {
        console.log(err);
      });
    }
  }

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)