Skip to content

Commit

Permalink
refactor: minor code cleanup to improve code health
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
clydin committed Jun 25, 2024
1 parent 943c2e9 commit d56c8de
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,7 @@ function analyzeClassStaticProperties(
shouldWrap = false;
break;
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} else if ((element as any).isStaticBlock()) {
} else if (element.isStaticBlock()) {
// Only need to analyze static blocks
const body = element.get('body');

Expand All @@ -387,9 +386,7 @@ function analyzeClassStaticProperties(
break;
}

const expression = body.find((n: NodePath<types.Node>) => n.isExpressionStatement()) as
| NodePath<types.ExpressionStatement>
| undefined;
const expression = body.find((n) => n.isExpressionStatement());

const assignmentExpression = expression?.get('expression');
if (assignmentExpression?.isAssignmentExpression()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ export default function (api: unknown, options: ApplicationPresetOptions) {
const includePlugins: string[] = [];

if (safariClassFieldScopeBugBrowsers === undefined) {
const browserslist = require('browserslist');
const browserslist = require('browserslist') as typeof import('browserslist');
safariClassFieldScopeBugBrowsers = new Set(
browserslist([
// Safari <15 is technically not supported via https://angular.dev/reference/versions#browser-support
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import { BuilderOutput } from '@angular-devkit/architect';
import { ForkOptions, fork } from 'child_process';
import { resolve } from 'path';
import { Observable } from 'rxjs';

const treeKill = require('tree-kill');
import treeKill from 'tree-kill';

export function runModuleAsObservableFork(
cwd: string,
Expand All @@ -32,7 +31,7 @@ export function runModuleAsObservableFork(
const forkOptions: ForkOptions = {
cwd,
execArgv,
} as {} as ForkOptions;
};

// TODO: support passing in a logger to use as stdio streams
// if (logger) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export class FileSystemEngineHost extends FileSystemEngineHostBase {

// Default handling code is for old tasks that incorrectly export `default` with non-ESM module
return from(import(path).then((mod) => (mod.default?.default || mod.default)())).pipe(
catchError(() => throwError(new UnregisteredTaskException(name))),
catchError(() => throwError(() => new UnregisteredTaskException(name))),
);
} catch {}
}
Expand Down
22 changes: 9 additions & 13 deletions scripts/devkit-admin.mts
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,12 @@ console.error = function (...args) {
originalConsole.error(colors.red(m), ...rest);
};

// eslint-disable-next-line @typescript-eslint/no-floating-promises
(async () => {
// code goes here
try {
const script = await import(`./${scriptName}.mjs`);
const exitCode = await script.default(args, cwd);
process.exitCode = exitCode || 0;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (err: any) {
console.error(err.stack);
process.exitCode = 99;
}
})();
try {
const script = await import(`./${scriptName}.mjs`);
const exitCode = await script.default(args, cwd);
process.exitCode = exitCode || 0;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (err: any) {
console.error(err.stack);
process.exitCode = 99;
}

0 comments on commit d56c8de

Please sign in to comment.