我正在为KeyboardJS构建声明源文件。该 API 是从加载 JavaScript 文件时实例化的静态对象 (KeyboardJS) 引用的。API 的一些方法嵌套在其他方法下。例如:
KeyboardJS.clear(keyCombo);
和
KeyboardJS.clear.key(key);
这是我的接口定义:
interface KeyboardJSStatic {
enable(): void;
disable(): void;
activeKeys(): string[];
on(keyCombo:string, onDownCallback?: (keyEvent: Event, keysPressed: string[], keyCombo: string) => {}, onUpCallback?: (keyEvent: Event, keysPressed: string[], keyCombo: string) => {}): KeyboardJSBinding;
clear(keyCombo: string): void;
clear.key(keyName: string): void;
locale(localeName: string): KeyboardJSLocale;
locale.register(localeName: string, localeDefinition: KeyboardJSLocale): void;
macro(keyCombo:string , keyNames: string[]): void;
macro.remove(keyCombo: string): void;
key: KeyboardJSKey;
combo: KeyboardJSCombo;
}
Visual Studio 2012 的 TypeScript 插件在 clear.key 行上生成并出错,建议在句点所在的位置使用分号。有没有人用类似的场景建立一个定义文件?谢谢!