从TypeScript定义导入解析和拒绝函数类型

时间:2017-07-01 21:12:21

标签: javascript node.js typescript typescript-typings typescript2.0

我有一个功能,我通过决心并拒绝它:

<TextView
    android:id="@+id/label"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="Sample Text "
    android:layout_below="@id/includething"/>

又名:

resolve: Function, reject: Function

我正在寻找这两个函数的类型定义(我知道它们很简单,但我也可以使用官方函数)。

我看到这个问题/答案: How to use Typescript with native ES6 Promises

但不幸的是,他们都没有提到使用的实际定义,任何人都知道吗?

1 个答案:

答案 0 :(得分:1)

promise构造函数的定义是:

declare type PromiseConstructorLike = 
    new <T>(executor: 
        (resolve: (value?: T | PromiseLike<T>) => void, 
         reject: (reason?: any) => void) => void) => PromiseLike<T>;

你可以复制它。