Skip to content

Commit

Permalink
Merge pull request #18377 from AriPerkkio/fix/builder-stats-typings
Browse files Browse the repository at this point in the history
Core: Fix builder stats typings to be optional
  • Loading branch information
ndelangen authored Jul 6, 2022
2 parents 1935e3f + b49b835 commit a5762c9
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
}>;
Expand Down
6 changes: 3 additions & 3 deletions lib/core-common/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,22 +186,22 @@ 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;
startTime: ReturnType<typeof process.hrtime>;
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[];
Expand Down
2 changes: 0 additions & 2 deletions lib/core-server/src/build-dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/core-server/src/utils/get-builders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit a5762c9

Please sign in to comment.