fix: add strict types to build scripts and remove all any usage

Replace all implicit and explicit any types in build scripts with
proper TypeScript Compiler API types (Decorator, ClassDeclaration,
MethodDeclaration, Identifier, SourceFile, etc.). Add PackageJson
and InjectableClassEntry interfaces. Fix return types, null checks,
and type assertions throughout all transformer scripts.
This commit is contained in:
Daniel Sogl
2026-03-21 16:11:27 -07:00
parent 6453f2ab78
commit 62956e429c
9 changed files with 160 additions and 108 deletions
+24 -11
View File
@@ -1,32 +1,45 @@
import { canHaveDecorators, ClassDeclaration, factory, getDecorators as tsGetDecorators, SyntaxKind } from 'typescript';
import {
canHaveDecorators,
ClassDeclaration,
ClassElement,
ConstructorDeclaration,
factory,
getDecorators as tsGetDecorators,
MethodDeclaration,
SyntaxKind,
} from 'typescript';
import { transformMethod } from './methods';
import { transformProperty } from './properties';
export function transformMembers(cls: ClassDeclaration) {
export function transformMembers(cls: ClassDeclaration): ClassElement[] {
const propertyIndices: number[] = [];
const members = cls.members.map((member: any, index: number) => {
// only process decorated members
const members = cls.members.map((member, index) => {
const memberDecorators = canHaveDecorators(member) ? tsGetDecorators(member) : undefined;
if (!memberDecorators || !memberDecorators.length) return member;
switch (member.kind) {
case SyntaxKind.MethodDeclaration:
return transformMethod(member);
return transformMethod(member as MethodDeclaration) ?? member;
case SyntaxKind.PropertyDeclaration:
propertyIndices.push(index);
return member;
case SyntaxKind.Constructor:
return factory.createConstructorDeclaration(undefined, member.parameters, member.body);
case SyntaxKind.Constructor: {
const ctor = member as ConstructorDeclaration;
return factory.createConstructorDeclaration(undefined, ctor.parameters, ctor.body);
}
default:
return member; // in case anything gets here by accident...
return member;
}
});
}) as ClassElement[];
propertyIndices.forEach((i: number) => {
const [getter, setter] = transformProperty(members, i) as any;
members.push(getter, setter);
const result = transformProperty(members, i);
if (Array.isArray(result)) {
const [getter, setter] = result;
members.push(getter, setter);
}
});
propertyIndices.reverse().forEach((i) => members.splice(i, 1));