@types/co
TypeScript icon, indicating that this package has built-in type declarations

4.6.6 • Public • Published

Installation

npm install --save @types/co

Summary

This package contains type definitions for co (https://github.com/tj/co#readme).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/co.

index.d.ts

// Since TS 3.6 the checker knows that the correct type of returned values and yielded values https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-6.html
// Generator<T, TReturn, TNext> => TReturn
// Function => ReturnType<Function>
// others => others
type ExtractType<I> = I extends { [Symbol.iterator]: () => Iterator<any, infer TReturn, any> } ? TReturn
    : I extends (...args: any[]) => any ? ReturnType<I>
    : I;

interface Co {
    <F extends (...args: any[]) => Iterator<any, any, any>>(fn: F, ...args: Parameters<F>): Promise<
        ExtractType<ReturnType<F>>
    >;
    default: Co;
    co: Co;
    wrap: <F extends (...args: any[]) => Iterator<any, any, any>>(
        fn: F,
    ) => (...args: Parameters<F>) => Promise<ExtractType<ReturnType<F>>>;
}

declare const co: Co;

export = co;

Additional Details

  • Last updated: Mon, 06 Nov 2023 22:41:05 GMT
  • Dependencies: none

Credits

These definitions were written by Doniyor Aliyev.

Readme

Keywords

none

Package Sidebar

Install

npm i @types/co

Weekly Downloads

82,044

Version

4.6.6

License

MIT

Unpacked Size

4.13 kB

Total Files

5

Last publish

Collaborators

  • types