Skip to content

Commit d56c8de

Browse files
committed
refactor: minor code cleanup to improve code health
Several smaller code changes to improve type information and remove now unneeded code structures based on improvements to both Node.js, TypeScript, and underlying dependencies.
1 parent 943c2e9 commit d56c8de

File tree

5 files changed

+15
-23
lines changed

5 files changed

+15
-23
lines changed

packages/angular/build/src/tools/babel/plugins/adjust-static-class-members.ts

+2-5
Original file line numberDiff line numberDiff line change
@@ -376,8 +376,7 @@ function analyzeClassStaticProperties(
376376
shouldWrap = false;
377377
break;
378378
}
379-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
380-
} else if ((element as any).isStaticBlock()) {
379+
} else if (element.isStaticBlock()) {
381380
// Only need to analyze static blocks
382381
const body = element.get('body');
383382

@@ -387,9 +386,7 @@ function analyzeClassStaticProperties(
387386
break;
388387
}
389388

390-
const expression = body.find((n: NodePath<types.Node>) => n.isExpressionStatement()) as
391-
| NodePath<types.ExpressionStatement>
392-
| undefined;
389+
const expression = body.find((n) => n.isExpressionStatement());
393390

394391
const assignmentExpression = expression?.get('expression');
395392
if (assignmentExpression?.isAssignmentExpression()) {

packages/angular_devkit/build_angular/src/tools/babel/presets/application.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ export default function (api: unknown, options: ApplicationPresetOptions) {
191191
const includePlugins: string[] = [];
192192

193193
if (safariClassFieldScopeBugBrowsers === undefined) {
194-
const browserslist = require('browserslist');
194+
const browserslist = require('browserslist') as typeof import('browserslist');
195195
safariClassFieldScopeBugBrowsers = new Set(
196196
browserslist([
197197
// Safari <15 is technically not supported via https://angular.dev/reference/versions#browser-support

packages/angular_devkit/build_angular/src/utils/run-module-as-observable-fork.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ import { BuilderOutput } from '@angular-devkit/architect';
1010
import { ForkOptions, fork } from 'child_process';
1111
import { resolve } from 'path';
1212
import { Observable } from 'rxjs';
13-
14-
const treeKill = require('tree-kill');
13+
import treeKill from 'tree-kill';
1514

1615
export function runModuleAsObservableFork(
1716
cwd: string,
@@ -32,7 +31,7 @@ export function runModuleAsObservableFork(
3231
const forkOptions: ForkOptions = {
3332
cwd,
3433
execArgv,
35-
} as {} as ForkOptions;
34+
};
3635

3736
// TODO: support passing in a logger to use as stdio streams
3837
// if (logger) {

packages/angular_devkit/schematics/tools/file-system-engine-host.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export class FileSystemEngineHost extends FileSystemEngineHostBase {
106106

107107
// Default handling code is for old tasks that incorrectly export `default` with non-ESM module
108108
return from(import(path).then((mod) => (mod.default?.default || mod.default)())).pipe(
109-
catchError(() => throwError(new UnregisteredTaskException(name))),
109+
catchError(() => throwError(() => new UnregisteredTaskException(name))),
110110
);
111111
} catch {}
112112
}

scripts/devkit-admin.mts

+9-13
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,12 @@ console.error = function (...args) {
3434
originalConsole.error(colors.red(m), ...rest);
3535
};
3636

37-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
38-
(async () => {
39-
// code goes here
40-
try {
41-
const script = await import(`./${scriptName}.mjs`);
42-
const exitCode = await script.default(args, cwd);
43-
process.exitCode = exitCode || 0;
44-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
45-
} catch (err: any) {
46-
console.error(err.stack);
47-
process.exitCode = 99;
48-
}
49-
})();
37+
try {
38+
const script = await import(`./${scriptName}.mjs`);
39+
const exitCode = await script.default(args, cwd);
40+
process.exitCode = exitCode || 0;
41+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
42+
} catch (err: any) {
43+
console.error(err.stack);
44+
process.exitCode = 99;
45+
}

0 commit comments

Comments
 (0)