Skip to content

Commit ee17915

Browse files
authored
Fix build breaks (#29977)
* Some callbacks in watchUtilities werent being strictly checked due to the structural fallback * Add direct dependeny on ms since mocha removed its impl * Manually init stats collection on base runner like mocha.run now does
1 parent 071708f commit ee17915

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
"@types/minimist": "latest",
4747
"@types/mkdirp": "latest",
4848
"@types/mocha": "latest",
49+
"@types/ms": "latest",
4950
"@types/node": "8.5.5",
5051
"@types/q": "latest",
5152
"@types/source-map-support": "latest",
@@ -74,6 +75,7 @@
7475
"mkdirp": "latest",
7576
"mocha": "latest",
7677
"mocha-fivemat-progress-reporter": "latest",
78+
"ms": "latest",
7779
"plugin-error": "latest",
7880
"pretty-hrtime": "^1.0.3",
7981
"prex": "^0.4.3",

src/compiler/watchUtilities.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -361,9 +361,9 @@ namespace ts {
361361
function getWatchFactoryWith<X, Y = undefined>(watchLogLevel: WatchLogLevel, log: (s: string) => void, getDetailWatchInfo: GetDetailWatchInfo<X, Y> | undefined,
362362
watchFile: (host: WatchFileHost, file: string, callback: FileWatcherCallback, watchPriority: PollingInterval) => FileWatcher,
363363
watchDirectory: (host: WatchDirectoryHost, directory: string, callback: DirectoryWatcherCallback, flags: WatchDirectoryFlags) => FileWatcher): WatchFactory<X, Y> {
364-
const createFileWatcher: CreateFileWatcher<WatchFileHost, PollingInterval, FileWatcherEventKind, undefined, X, Y> = getCreateFileWatcher(watchLogLevel, watchFile);
364+
const createFileWatcher: CreateFileWatcher<WatchFileHost, PollingInterval, FileWatcherEventKind, never, X, Y> = getCreateFileWatcher(watchLogLevel, watchFile);
365365
const createFilePathWatcher: CreateFileWatcher<WatchFileHost, PollingInterval, FileWatcherEventKind, Path, X, Y> = watchLogLevel === WatchLogLevel.None ? watchFilePath : createFileWatcher;
366-
const createDirectoryWatcher: CreateFileWatcher<WatchDirectoryHost, WatchDirectoryFlags, undefined, undefined, X, Y> = getCreateFileWatcher(watchLogLevel, watchDirectory);
366+
const createDirectoryWatcher: CreateFileWatcher<WatchDirectoryHost, WatchDirectoryFlags, undefined, never, X, Y> = getCreateFileWatcher(watchLogLevel, watchDirectory);
367367
return {
368368
watchFile: (host, file, callback, pollingInterval, detailInfo1, detailInfo2) =>
369369
createFileWatcher(host, file, callback, pollingInterval, /*passThrough*/ undefined, detailInfo1, detailInfo2, watchFile, log, "FileWatcher", getDetailWatchInfo),
@@ -402,7 +402,7 @@ namespace ts {
402402
}
403403
}
404404

405-
function createFileWatcherWithLogging<H, T, U, V, X, Y>(host: H, file: string, cb: WatchCallback<U, V>, flags: T, passThrough: V | undefined, detailInfo1: X | undefined, detailInfo2: Y | undefined, addWatch: AddWatch<H, T, U, undefined>, log: (s: string) => void, watchCaption: string, getDetailWatchInfo: GetDetailWatchInfo<X, Y> | undefined): FileWatcher {
405+
function createFileWatcherWithLogging<H, T, U, V, X, Y>(host: H, file: string, cb: WatchCallback<U, V>, flags: T, passThrough: V | undefined, detailInfo1: X | undefined, detailInfo2: Y | undefined, addWatch: AddWatch<H, T, U, V>, log: (s: string) => void, watchCaption: string, getDetailWatchInfo: GetDetailWatchInfo<X, Y> | undefined): FileWatcher {
406406
log(`${watchCaption}:: Added:: ${getWatchInfo(file, flags, detailInfo1, detailInfo2, getDetailWatchInfo)}`);
407407
const watcher = createFileWatcherWithTriggerLogging(host, file, cb, flags, passThrough, detailInfo1, detailInfo2, addWatch, log, watchCaption, getDetailWatchInfo);
408408
return {
@@ -413,7 +413,7 @@ namespace ts {
413413
};
414414
}
415415

416-
function createDirectoryWatcherWithLogging<H, T, U, V, X, Y>(host: H, file: string, cb: WatchCallback<U, V>, flags: T, passThrough: V | undefined, detailInfo1: X | undefined, detailInfo2: Y | undefined, addWatch: AddWatch<H, T, U, undefined>, log: (s: string) => void, watchCaption: string, getDetailWatchInfo: GetDetailWatchInfo<X, Y> | undefined): FileWatcher {
416+
function createDirectoryWatcherWithLogging<H, T, U, V, X, Y>(host: H, file: string, cb: WatchCallback<U, V>, flags: T, passThrough: V | undefined, detailInfo1: X | undefined, detailInfo2: Y | undefined, addWatch: AddWatch<H, T, U, V>, log: (s: string) => void, watchCaption: string, getDetailWatchInfo: GetDetailWatchInfo<X, Y> | undefined): FileWatcher {
417417
const watchInfo = `${watchCaption}:: Added:: ${getWatchInfo(file, flags, detailInfo1, detailInfo2, getDetailWatchInfo)}`;
418418
log(watchInfo);
419419
const start = timestamp();
@@ -432,7 +432,7 @@ namespace ts {
432432
};
433433
}
434434

435-
function createFileWatcherWithTriggerLogging<H, T, U, V, X, Y>(host: H, file: string, cb: WatchCallback<U, V>, flags: T, passThrough: V | undefined, detailInfo1: X | undefined, detailInfo2: Y | undefined, addWatch: AddWatch<H, T, U, undefined>, log: (s: string) => void, watchCaption: string, getDetailWatchInfo: GetDetailWatchInfo<X, Y> | undefined): FileWatcher {
435+
function createFileWatcherWithTriggerLogging<H, T, U, V, X, Y>(host: H, file: string, cb: WatchCallback<U, V>, flags: T, passThrough: V | undefined, detailInfo1: X | undefined, detailInfo2: Y | undefined, addWatch: AddWatch<H, T, U, V>, log: (s: string) => void, watchCaption: string, getDetailWatchInfo: GetDetailWatchInfo<X, Y> | undefined): FileWatcher {
436436
return addWatch(host, file, (fileName, cbOptional) => {
437437
const triggerredInfo = `${watchCaption}:: Triggered with ${fileName} ${cbOptional !== undefined ? cbOptional : ""}:: ${getWatchInfo(file, flags, detailInfo1, detailInfo2, getDetailWatchInfo)}`;
438438
log(triggerredInfo);

src/testRunner/parallel/host.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace Harness.Parallel.Host {
77
const Base = Mocha.reporters.Base;
88
const color = Base.color;
99
const cursor = Base.cursor;
10-
const ms = require("mocha/lib/ms") as typeof import("mocha/lib/ms");
10+
const ms = require("ms") as typeof import("ms");
1111
const readline = require("readline") as typeof import("readline");
1212
const os = require("os") as typeof import("os");
1313
const tty = require("tty") as typeof import("tty");
@@ -530,6 +530,8 @@ namespace Harness.Parallel.Host {
530530

531531
const replayRunner = new Mocha.Runner(new Mocha.Suite(""), /*delay*/ false);
532532
replayRunner.started = true;
533+
const createStatsCollector = require("mocha/lib/stats-collector");
534+
createStatsCollector(replayRunner); // manually init stats collector like mocha.run would
533535

534536
const consoleReporter = new Base(replayRunner);
535537
patchStats(consoleReporter.stats);

0 commit comments

Comments
 (0)