微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

WebExtensions实验API schema.json转换为Typescript声明

如何解决WebExtensions实验API schema.json转换为Typescript声明

我想将自己的WebExtensions Experiment API的schema.json文件转换为TypeScript声明文件

来自此:
schema.json

[
  {
    "namespace": "tabsExtra","functions": [
      {
        "name": "create","type": "function","description": "tabs.create extra API.","async": true,"parameters": [
                    {
                        "name": "createProperties","type": "object","optional": true,"properties": {
                            "url": { "type": "string" },"active": { "type": "boolean","optional": true }
            }
                    }
        ]
      },{
        "name": "update","description": "Update tab extra API.","parameters": [
                    {
                        "name": "url","type": "string"
                    }
                ]
      }
    ]
  }
]

对此:
global.d.ts

declare namespace browser.tabsExtra {
    function create({url: string,active: boolean}): Promise<void>;
    function update(url: string): Promise<void>;
}

我尝试使用json-schema-to-typescript软件包,但得到[k: string]: unkNown;。 看起来不是为了这个。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。