Skip to content

Commit

Permalink
🤖 Merge PR #49972 [undertaker] remove 'any' from TaskFunctionBase's r…
Browse files Browse the repository at this point in the history
…eturn type union by @kazarmy

* fix: remove 'any' from TaskFunctionBase's return type union

* Fix glob-watcher tests

* Update types/undertaker/undertaker-tests.ts

Co-authored-by: Ron Buckton <ron.buckton@microsoft.com>

* Remove rxjs dependency

* Add explicit 'any' return type

* Use '~' instead of '^' in package.json

Co-authored-by: Ron Buckton <ron.buckton@microsoft.com>
  • Loading branch information
kazarmy and rbuckton committed Dec 10, 2020
1 parent 526f5ee commit 17c5828
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
4 changes: 2 additions & 2 deletions types/glob-watcher/glob-watcher-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ function test() {
optionsTypeTest(opts1);
optionsTypeTest(opts2);

const taskFunc: Undertaker.TaskFunction = () => "";
const taskFunc: Undertaker.TaskFunction = async () => "";

const cb = () => {
const cb = async () => {
console.log("watch change!");
};

Expand Down
4 changes: 2 additions & 2 deletions types/undertaker/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

/// <reference types="node" />
import * as Registry from "undertaker-registry";
import { Duplex } from "stream";
import { AsyncTask } from "async-done";
import { EventEmitter } from "events";

declare namespace Undertaker {
Expand All @@ -23,7 +23,7 @@ declare namespace Undertaker {
}

interface TaskFunctionBase {
(done: (error?: Error | null) => void): void | Duplex | NodeJS.Process | Promise<never> | any;
(done: (error?: Error | null) => void): ReturnType<AsyncTask>;
}

interface TaskFunction extends TaskFunctionBase, TaskFunctionParams {}
Expand Down
6 changes: 6 additions & 0 deletions types/undertaker/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"private": true,
"dependencies": {
"async-done": "~1.3.2"
}
}
14 changes: 14 additions & 0 deletions types/undertaker/undertaker-tests.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { exec } from "child_process";
import { EventEmitter } from "events";
import * as fs from "fs";
import Undertaker = require("undertaker");
import Registry = require("undertaker-registry");
Expand Down Expand Up @@ -34,6 +36,18 @@ const {
flags,
} = taker.task("task4").unwrap();

taker.task("task5", () => {
const emitter = new EventEmitter();
setTimeout(() => emitter.emit("done"), 1000);
return emitter;
});

taker.task("task6", () => exec("ls"));

declare const task7: () => {
subscribe(next?: (v: any) => void, error?: (e: any) => void, complete?: () => void): any;
};
taker.task("task7", task7);
taker.task("combined", taker.series("task1", "task2"));

taker.task("all", taker.parallel("combined", "task3"));
Expand Down

0 comments on commit 17c5828

Please sign in to comment.