mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 06:47:03 +00:00
@@ -0,0 +1,30 @@
|
||||
import co = require('co');
|
||||
|
||||
function* gen(num: number, str: string, arr: number[], obj: object, fun: () => void) {
|
||||
return num;
|
||||
}
|
||||
|
||||
co(gen, 42, 'forty-two', [42], { value: 42 }, () => {})
|
||||
.then((num: number) => {}, (err: Error) => {})
|
||||
.catch((err: Error) => {});
|
||||
|
||||
co.default(gen, 42, 'forty-two', [42], { value: 42 }, () => {})
|
||||
.then((num: number) => {}, (err: Error) => {})
|
||||
.catch((err: Error) => {});
|
||||
|
||||
co.co(gen, 42, 'forty-two', [42], { value: 42 }, () => {})
|
||||
.then((num: number) => {}, (err: Error) => {})
|
||||
.catch((err: Error) => {});
|
||||
|
||||
co.wrap(gen)(42, 'forty-two', [42], { value: 42 }, () => {})
|
||||
.then((num: number) => {}, (err: Error) => {})
|
||||
.catch((err: Error) => {});
|
||||
|
||||
// $ExpectError
|
||||
co(gen, 42, 'forty-two', [42], { value: 42 }, () => {}).then((str: string) => {});
|
||||
|
||||
// $ExpectError
|
||||
co.wrap(gen)();
|
||||
|
||||
// $ExpectError
|
||||
co.wrap(gen)('forty-two');
|
||||
Vendored
+18
@@ -0,0 +1,18 @@
|
||||
// Type definitions for co 4.6
|
||||
// Project: https://github.com/tj/co#readme
|
||||
// Definitions by: Doniyor Aliyev <https://github.com/doniyor2109>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 3.1
|
||||
|
||||
type ExtractType<T> = T extends IterableIterator<infer R> ? R : never;
|
||||
|
||||
interface Co {
|
||||
<F extends (...args: any[]) => Generator>(fn: F, ...args: Parameters<F>): Promise<ExtractType<ReturnType<F>>>;
|
||||
default: Co;
|
||||
co: Co;
|
||||
wrap: <F extends (...args: any[]) => Generator>(fn: F) => (...args: Parameters<F>) => Promise<ExtractType<ReturnType<F>>>;
|
||||
}
|
||||
|
||||
declare const co: Co;
|
||||
|
||||
export = co;
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"co-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user