From 57c5f829094860e6a25eb0363c70db7ebe1f2c1c Mon Sep 17 00:00:00 2001 From: Olegs Jeremejevs Date: Sat, 16 Mar 2019 23:30:48 +1100 Subject: [PATCH] webpack: Fix startTime and endTime in Stats --- types/webpack/index.d.ts | 4 ++-- types/webpack/webpack-tests.ts | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/types/webpack/index.d.ts b/types/webpack/index.d.ts index fe3dc638e1..d540a165c4 100644 --- a/types/webpack/index.d.ts +++ b/types/webpack/index.d.ts @@ -1131,8 +1131,8 @@ declare namespace webpack { abstract class Stats { compilation: compilation.Compilation; hash?: string; - startTime?: Date; - endTime?: Date; + startTime?: number; + endTime?: number; /** Returns true if there were errors while compiling. */ hasErrors(): boolean; /** Returns true if there were warnings while compiling. */ diff --git a/types/webpack/webpack-tests.ts b/types/webpack/webpack-tests.ts index 487d28b8f6..6c8bd52ba7 100644 --- a/types/webpack/webpack-tests.ts +++ b/types/webpack/webpack-tests.ts @@ -895,3 +895,11 @@ profiling = new webpack.debug.ProfilingPlugin({ outputPath: './path.json' }); configuration = { plugins: [profiling] }; + +compiler.hooks.done.tap('foo', stats => { + if (stats.startTime === undefined || stats.endTime === undefined) { + throw new Error('Well, this is odd'); + } + + console.log(`Compiled in ${stats.endTime - stats.startTime}ms`); +});