Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core: Fix builder stats typings to be optional #18377

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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