向全局屏幕添加新方法时无法满足tslint的要求

Unable to satisfy tslint's requirement when adding a new method to global Screen

我希望能够在不同的网络浏览器中使用屏幕方向锁定 (https://developer.mozilla.org/en-US/docs/Web/API/ScreenOrientation/lock) 功能。

这是我的尝试:

export function lock(orientation: OrientationLockType) {
    const lockOrientation: (orientation: OrientationLockType) => boolean = screen.lockOrientation || screen.mozLockOrientation || screen.msLockOrientation || screen.orientation.lock;
    lockOrientation(orientation);
}

视觉代码标记 screen.mozLockOrientation 因为它不存在于 Screen 类型中。

所以我加上这个

declare global {
    interface Screen {
        mozLockOrientation: (orientation: OrientationLockType) => boolean;
    }
}

然而 tslint 不喜欢 mozLockOrientation 的类型声明,因为它不是方法签名。

所以我的问题是:

1) 什么是方法签名,如何将上面的转换为方法签名?

2) 如何找到 screen.orientation.lock 的正确类型?我尝试了 orientation: { lock: (orientation: OrientationLockType) => boolean }; 但我想知道是否有更多权威来源。

1) 以下是编写等效方法签名的方式:

declare global {
    interface Screen {
        mozLockOrientation(orientation: OrientationLockType): boolean;
    }
}

2) 如果从 MDN 页面跟随 link 到 the specification,它有一个与 TypeScript 相当相似的 WebIDL 声明,并指示 return 类型的 Promise<void> 而不是 boolean.