如何让 javascript 自动完成功能为 navigator.bluetooth 工作?

问题描述

网络编程的新手,甚至是蓝牙网络编程的新手。

我正在试用一些 IDE 来帮助我完成自动完成。但是我还没有让他们中的任何一个为 navigator.bluetooth 命名空间工作。有什么技巧可以让它发挥作用吗?该代码在 Chrome 中运行良好。我怀疑我必须在正确的位置安装 navigator.bluetooth 才能让 IDE 意识到它? (虽然它随 Chrome 开箱即用,所以我不确定是不是这样)

我怀疑答案是微不足道的,非常感谢!

navigator.bluetooth.requestDevice()
      .then(device => {
        this.device = device;
        return device.gatt.connect();

webstorm autocomplete image

自动完成工作的其他方面:

enter image description here

解决方法

我相信您正在寻找的是网络蓝牙的类型定义:https://www.npmjs.com/package/@types/web-bluetooth