Merge pull request #18377 from AriPerkkio/fix/builder-stats-typings

Core: Fix builder stats typings to be optional
This commit is contained in:
Norbert de Langen 2022-07-07 00:03:20 +02:00 committed by GitHub
commit a5762c99cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 7 deletions

View File

@ -6,7 +6,7 @@ export interface Builder<Config, Stats> {
router: Router;
server: Server;
}) => Promise<void | {
stats: Stats;
stats?: Stats;
totalTime: ReturnType<typeof process.hrtime>;
bail: (e?: Error) => Promise<void>;
}>;

View File

@ -186,7 +186,7 @@ export interface StorybookConfigOptions {
export type Options = LoadOptions & StorybookConfigOptions & CLIOptions & BuilderOptions;
export interface Builder<Config, Stats> {
export interface Builder<Config, BuilderStats extends Stats = Stats> {
getConfig: (options: Options) => Promise<Config>;
start: (args: {
options: Options;
@ -194,14 +194,14 @@ export interface Builder<Config, Stats> {
router: Router;
server: Server;
}) => Promise<void | {
stats: Stats;
stats?: BuilderStats;
totalTime: ReturnType<typeof process.hrtime>;
bail: (e?: Error) => Promise<void>;
}>;
build: (arg: {
options: Options;
startTime: ReturnType<typeof process.hrtime>;
}) => Promise<void | Stats>;
}) => Promise<void | BuilderStats>;
bail: (e?: Error) => Promise<void>;
corePresets?: string[];
overridePresets?: string[];

View File

@ -118,9 +118,7 @@ export async function buildDevStandalone(options: CLIOptions & LoadOptions & Bui
if (options.smokeTest) {
const warnings: Error[] = [];
// @ts-ignore
warnings.push(...((managerStats && managerStats.toJson().warnings) || []));
// @ts-ignore
warnings.push(...((managerStats && previewStats.toJson().warnings) || []));
const problems = warnings

View File

@ -21,7 +21,7 @@ async function getPreviewBuilder(builderName: string, configDir: string) {
export async function getBuilders({
presets,
configDir,
}: Options): Promise<Builder<unknown, unknown>[]> {
}: Options): Promise<Builder<unknown>[]> {
const core = await presets.apply<CoreConfig>('core', undefined);
const builderName = typeof core?.builder === 'string' ? core.builder : core?.builder?.name;