Does TypeScript allow type aliases?

后端 未结 3 1451
广开言路
广开言路 2020-12-13 23:27

So I wish I could use an alias to an ugly type that looks like this:

Maybe, Problem>>[]

Something

3条回答
  •  星月不相逢
    2020-12-13 23:55

    A poor man's solution is to declare a dummy variable (e.g. t) with the desired type and use typeof t instead of the long type expression:

    var t: { (x: number, f: { (foo: string, bar:boolean): void }): void };
    
    var f: typeof t;
    var g: typeof t;
    

提交回复
热议问题