mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-06-04 19:42:46 +08:00
Add types for task-graph-runner (#27371)
This commit is contained in:
22
types/task-graph-runner/index.d.ts
vendored
Normal file
22
types/task-graph-runner/index.d.ts
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
// Type definitions for task-graph-runner 1.0
|
||||
// Project: https://github.com/thejameskyle/task-graph-runner#readme
|
||||
// Definitions by: Melvin Groenhoff <https://github.com/mgroenhoff>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
|
||||
export = taskGraphRunner;
|
||||
|
||||
declare function taskGraphRunner<Item, Result>(opts: taskGraphRunner.Opts<Item, Result>): Promise<taskGraphRunner.Results<Item, Result>>;
|
||||
|
||||
declare namespace taskGraphRunner {
|
||||
interface Opts<Item, Result> {
|
||||
graph: Map<Item, Item[]>;
|
||||
task: (item: Item) => Result;
|
||||
force?: boolean;
|
||||
}
|
||||
|
||||
interface Results<Item, Result> {
|
||||
values: Map<Item, Result>;
|
||||
safe: boolean;
|
||||
}
|
||||
}
|
||||
17
types/task-graph-runner/task-graph-runner-tests.ts
Normal file
17
types/task-graph-runner/task-graph-runner-tests.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import taskGraphRunner, { Opts, Results } from 'task-graph-runner';
|
||||
|
||||
const graph = new Map([
|
||||
["task-a", ["task-d"]],
|
||||
["task-b", ["task-d", "task-a"]],
|
||||
["task-c", ["task-d"]],
|
||||
["task-d", []],
|
||||
]);
|
||||
|
||||
async function task(name: string) {
|
||||
const result = await Promise.resolve(name);
|
||||
return result;
|
||||
}
|
||||
|
||||
let results = taskGraphRunner({ graph, task });
|
||||
|
||||
results = taskGraphRunner({ graph, task, force: true });
|
||||
24
types/task-graph-runner/tsconfig.json
Normal file
24
types/task-graph-runner/tsconfig.json
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"task-graph-runner-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/task-graph-runner/tslint.json
Normal file
1
types/task-graph-runner/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user