mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-15 18:13:38 +08:00
refactor(@angular-devkit/architect): assert catch clause variable type before usage
Prepares the `@angular-devkit/architect` 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
3c4ca3fa7f
commit
1b9880c5cb
@ -245,7 +245,7 @@ async function getBuilder(builderPath: string): Promise<any> {
|
|||||||
try {
|
try {
|
||||||
return require(builderPath);
|
return require(builderPath);
|
||||||
} catch (e) {
|
} 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.
|
// Load the ESM configuration file using the TypeScript dynamic import workaround.
|
||||||
// Once TypeScript provides support for keeping the dynamic import this workaround can be
|
// Once TypeScript provides support for keeping the dynamic import this workaround can be
|
||||||
// changed to a direct dynamic import.
|
// changed to a direct dynamic import.
|
||||||
|
@ -136,13 +136,10 @@ describe('architect', () => {
|
|||||||
await run.stop();
|
await run.stop();
|
||||||
});
|
});
|
||||||
|
|
||||||
it(`errors when target configuration doesn't exists`, async () => {
|
it(`errors when target configuration does not exist`, async () => {
|
||||||
try {
|
await expectAsync(architect.scheduleBuilder('test:test:invalid', {})).toBeRejectedWithError(
|
||||||
await architect.scheduleBuilder('test:test:invalid', {});
|
'Job name "test:test:invalid" does not exist.',
|
||||||
throw new Error('should have thrown');
|
);
|
||||||
} catch (err) {
|
|
||||||
expect(err.message).toContain('Job name "test:test:invalid" does not exist.');
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('errors when builder cannot be resolved', async () => {
|
it('errors when builder cannot be resolved', async () => {
|
||||||
|
@ -179,7 +179,7 @@ async function _executeTarget(
|
|||||||
logs.forEach((l) => parentLogger.next(l));
|
logs.forEach((l) => parentLogger.next(l));
|
||||||
|
|
||||||
parentLogger.fatal('Exception:');
|
parentLogger.fatal('Exception:');
|
||||||
parentLogger.fatal(err.stack);
|
parentLogger.fatal((err instanceof Error && err.stack) || `${err}`);
|
||||||
|
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user