mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2026-04-13 00:00:10 +08:00
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:
@@ -1,11 +1,21 @@
|
||||
import { factory, PropertyDeclaration } from 'typescript';
|
||||
import {
|
||||
ClassElement,
|
||||
factory,
|
||||
GetAccessorDeclaration,
|
||||
Identifier,
|
||||
PropertyDeclaration,
|
||||
SetAccessorDeclaration,
|
||||
} from 'typescript';
|
||||
|
||||
import { getDecorator, getDecoratorName } from '../helpers';
|
||||
|
||||
export function transformProperty(members: any[], index: number) {
|
||||
export function transformProperty(
|
||||
members: ClassElement[],
|
||||
index: number
|
||||
): [GetAccessorDeclaration, SetAccessorDeclaration] | PropertyDeclaration {
|
||||
const property = members[index] as PropertyDeclaration,
|
||||
decorator = getDecorator(property),
|
||||
decoratorName = getDecoratorName(decorator);
|
||||
decoratorName = decorator ? getDecoratorName(decorator) : undefined;
|
||||
|
||||
let type: 'cordova' | 'instance';
|
||||
|
||||
@@ -22,6 +32,8 @@ export function transformProperty(members: any[], index: number) {
|
||||
return property;
|
||||
}
|
||||
|
||||
const propertyName = (property.name as Identifier).text;
|
||||
|
||||
const getter = factory.createGetAccessorDeclaration(
|
||||
undefined,
|
||||
property.name,
|
||||
@@ -31,7 +43,7 @@ export function transformProperty(members: any[], index: number) {
|
||||
factory.createReturnStatement(
|
||||
factory.createCallExpression(factory.createIdentifier(type + 'PropertyGet'), undefined, [
|
||||
factory.createThis(),
|
||||
factory.createStringLiteral((property.name as any).text),
|
||||
factory.createStringLiteral(propertyName),
|
||||
])
|
||||
),
|
||||
])
|
||||
@@ -45,7 +57,7 @@ export function transformProperty(members: any[], index: number) {
|
||||
factory.createExpressionStatement(
|
||||
factory.createCallExpression(factory.createIdentifier(type + 'PropertySet'), undefined, [
|
||||
factory.createThis(),
|
||||
factory.createStringLiteral((property.name as any).text),
|
||||
factory.createStringLiteral(propertyName),
|
||||
factory.createIdentifier('value'),
|
||||
])
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user