Javascript 有没有办法为绑定函数添加类型定义/声明?

Javascript 有没有办法为绑定函数添加类型定义/声明?,javascript,typescript,type-declaration,type-definition,Javascript,Typescript,Type Declaration,Type Definition,我现在正在学习TypeScript,我一直想创建和贡献我自己的typedef文件 因此,由于这个绑定函数,我最近很难让Intellisense处理该类型 declare module 'jshue' { export interface IHue { discover: () => Promise<Array<any>>, bridge: (ip: string) => any } var jsHue:I

我现在正在学习TypeScript,我一直想创建和贡献我自己的typedef文件

因此,由于这个绑定函数,我最近很难让Intellisense处理该类型

declare module 'jshue' {
    export interface IHue {
        discover: () => Promise<Array<any>>,
        bridge: (ip: string) => any
    }
    var jsHue:IHue = jsHueAPI.bind(null, fetch, Response, JSON, Promise);
    export default jsHue;
}
如果我在声明jsHue时声明了一个类型,它会起作用,只是它会破坏使用类型定义文件的目的

import jsHue, { IHue } from 'jshue';
const hue:IHue = jsHue();
还有,有没有一种方法可以避免用jsHue()声明新变量

有没有其他的解决办法


嗯,你不想使用
bind
,你想使用
call
?没有理由部分应用该函数。或者,如果库就是这样编写的(您不能更改它,只想提供类型),那么您可能应该使用
var jsHue:()=>IHueHi@Bergi,var jsHue:()=>IHue;作品非常感谢你!因此,我无法避免在type def文件中声明jsHue()?如果库一直这样编写就不行。呃,你不想使用
bind
,你想使用
call
?没有理由部分应用该函数。或者,如果库就是这样编写的(您不能更改它,只想提供类型),那么您可能应该使用
var jsHue:()=>IHueHi@Bergi,var jsHue:()=>IHue;作品非常感谢你!因此,我无法避免在类型def文件中声明jsHue()?如果库一直这样编写,就无法避免。
import jsHue, { IHue } from 'jshue';
const hue:IHue = jsHue();