mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-05 12:22:45 +02:00
refactor: improve types (#6866)
This commit is contained in:
parent
8e934450d8
commit
a4e37c4054
4 changed files with 26 additions and 50 deletions
|
@ -23,16 +23,7 @@ export default function preload(
|
|||
const matches = matchRoutes(routes, pathname);
|
||||
|
||||
return Promise.all(
|
||||
matches.map((match) => {
|
||||
const {component} = match.route;
|
||||
|
||||
// @ts-expect-error: ComponentCreator injected this method.
|
||||
if (component && component.preload) {
|
||||
// @ts-expect-error: checked above.
|
||||
return component.preload();
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}),
|
||||
// @ts-expect-error: ComponentCreator injected this method.
|
||||
matches.map((match) => match.route.component?.preload?.()),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -236,15 +236,20 @@ export function applyConfigurePostCss(
|
|||
return config;
|
||||
}
|
||||
|
||||
declare global {
|
||||
interface Error {
|
||||
/** @see https://webpack.js.org/api/node/#error-handling */
|
||||
details: unknown;
|
||||
}
|
||||
}
|
||||
|
||||
export function compile(config: Configuration[]): Promise<void> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const compiler = webpack(config);
|
||||
compiler.run((err, stats) => {
|
||||
if (err) {
|
||||
logger.error(err.stack || err);
|
||||
// @ts-expect-error: see https://webpack.js.org/api/node/#error-handling
|
||||
if (err.details) {
|
||||
// @ts-expect-error: see https://webpack.js.org/api/node/#error-handling
|
||||
logger.error(err.details);
|
||||
}
|
||||
reject(err);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue