mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-20 05:24:57 +08:00
refactor(@angular-devkit/build-webpack): assert catch clause variable type before usage
Prepares the `@angular-devkit/build-webpack` package for the eventual change of enabling the TypeScript `useUnknownInCatchVariables` option. This option provides additional code safety by ensuring that the catch clause variable is the proper type before attempting to access its properties. Similar changes will be needed in the other packages in the repository prior to enabling `useUnknownInCatchVariables`.
This commit is contained in:
parent
6a3c0b0db5
commit
3c4ca3fa7f
@ -90,7 +90,7 @@ export async function getWebpackConfig(configPath: string): Promise<Configuratio
|
||||
try {
|
||||
return require(configPath);
|
||||
} catch (e) {
|
||||
if (e.code === 'ERR_REQUIRE_ESM') {
|
||||
if ((e as NodeJS.ErrnoException).code === 'ERR_REQUIRE_ESM') {
|
||||
// Load the ESM configuration file using the TypeScript dynamic import workaround.
|
||||
// Once TypeScript provides support for keeping the dynamic import this workaround can be
|
||||
// changed to a direct dynamic import.
|
||||
|
@ -105,7 +105,7 @@ export function runWebpack(
|
||||
} catch (err) {
|
||||
if (err) {
|
||||
context.logger.error(
|
||||
`\nAn error occurred during the build:\n${(err && err.stack) || err}`,
|
||||
`\nAn error occurred during the build:\n${err instanceof Error ? err.stack : err}`,
|
||||
);
|
||||
}
|
||||
throw err;
|
||||
|
Loading…
x
Reference in New Issue
Block a user