Function isThenableType

  • Determines whether a type is thenable and thus can be used with await.

    Parameters

    • typeChecker: TypeChecker
    • node: Node
    • type: Type

    Returns boolean

    Example

    declare const node: ts.Node;
    declare const type: ts.Type;
    declare const typeChecker: ts.TypeChecker;

    if (isThenableType(typeChecker, node, type)) {
    // ...
    }
  • Determines whether a type is thenable and thus can be used with await.

    Parameters

    • typeChecker: TypeChecker
    • node: Expression
    • Optional type: Type

    Returns boolean

    Example

    declare const expression: ts.Expression;
    declare const typeChecker: ts.TypeChecker;

    if (isThenableType(typeChecker, expression)) {
    // ...
    }

    Example

    declare const expression: ts.Expression;
    declare const typeChecker: ts.TypeChecker;
    declare const type: ts.Type;

    if (isThenableType(typeChecker, expression, type)) {
    // ...
    }