refactor(build): remove deprecated typescript functions

This commit is contained in:
Daniel Sogl
2021-09-27 22:04:25 +02:00
parent 9e38c6b922
commit 66f5bbaa4e
6 changed files with 55 additions and 80 deletions
+15 -11
View File
@@ -3,13 +3,9 @@ import { camelCase, clone } from 'lodash';
import { join, resolve } from 'path';
import {
ArrayLiteralExpression,
createArrayLiteral,
createLiteral,
createNumericLiteral,
createObjectLiteral,
createPropertyAssignment,
Decorator,
Expression,
factory,
Node,
ObjectLiteralElementLike,
ObjectLiteralExpression,
@@ -102,9 +98,14 @@ export function convertValueToLiteral(val: any) {
return objectToObjectLiteral(val);
}
if (typeof val === 'number') {
return createNumericLiteral(String(val));
return factory.createNumericLiteral(val);
}
if (typeof val === 'string') {
return factory.createStringLiteral(val);
}
if (typeof val === 'boolean') {
return val ? factory.createTrue() : factory.createFalse();
}
return createLiteral(val);
}
/**
@@ -115,21 +116,24 @@ export function convertValueToLiteral(val: any) {
*/
function objectToObjectLiteral(obj: { [key: string]: any }): ObjectLiteralExpression {
const newProperties: ObjectLiteralElementLike[] = Object.keys(obj).map((key: string): ObjectLiteralElementLike => {
return createPropertyAssignment(createLiteral(key), convertValueToLiteral(obj[key]) as Expression);
return factory.createPropertyAssignment(
factory.createStringLiteral(key),
convertValueToLiteral(obj[key]) as Expression
);
});
return createObjectLiteral(newProperties);
return factory.createObjectLiteralExpression(newProperties);
}
/**
* FROM STENCIL
* Convert a js array into typescript AST
* @param list array
* @param list arrayÏ
* @returns Typescript Array Literal Expression
*/
function arrayToArrayLiteral(list: any[]): ArrayLiteralExpression {
const newList: any[] = list.map(convertValueToLiteral);
return createArrayLiteral(newList);
return factory.createArrayLiteralExpression(newList);
}
export function getMethodsForDecorator(decoratorName: string) {