From 86e6278fea0b4907147b35855af06104255fc313 Mon Sep 17 00:00:00 2001 From: Michael Kuryshev Date: Thu, 6 Jan 2022 19:01:01 +0100 Subject: [PATCH] types: more `build` overload definitions (#1911) --- lib/shared/types.ts | 2 ++ scripts/ts-type-tests.js | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/lib/shared/types.ts b/lib/shared/types.ts index 721c70d6513..0f1796ac09d 100644 --- a/lib/shared/types.ts +++ b/lib/shared/types.ts @@ -449,7 +449,9 @@ export interface AnalyzeMetafileOptions { * Documentation: https://esbuild.github.io/api/#build-api */ export declare function build(options: BuildOptions & { write: false }): Promise; +export declare function build(options: BuildOptions & { incremental: true, metafile: true }): Promise; export declare function build(options: BuildOptions & { incremental: true }): Promise; +export declare function build(options: BuildOptions & { metafile: true }): Promise; export declare function build(options: BuildOptions): Promise; /** diff --git a/scripts/ts-type-tests.js b/scripts/ts-type-tests.js index 08fa06515c8..62ac1306314 100644 --- a/scripts/ts-type-tests.js +++ b/scripts/ts-type-tests.js @@ -60,6 +60,21 @@ const tests = { result.rebuild.dispose() } `, + metafileTrue: ` + import {build, analyzeMetafile} from 'esbuild'; + build({ metafile: true }).then(result => { + analyzeMetafile(result.metafile) + }) + `, + incrementalAndMetafileTrue: ` + import {build, analyzeMetafile} from 'esbuild'; + build({ + incremental: true, + metafile: true, + }).then(result => { + analyzeMetafile(result.metafile) + }) + `, ifRebuild: ` import * as esbuild from 'esbuild' let options: any