UNPKG

typeorm-codebase-sync

Version:

Automatically update your codebase to add migrations, entities and subscribers to your `data-source.ts` file

19 lines 1.1 kB
import ts from "typescript"; // expression: *[] as any[]*, updater: (valueExpression: *[]*) => expression // expression: *<any[]>[]*, updater: (valueExpression: *[]*) => expression // relevant for any expression value, not necessarily just for arrays export function updateWithTypeExpression(expression, updater) { if (ts.isAsExpression(expression)) return ts.factory.updateAsExpression(expression, isWithTypeExpression(expression.expression) ? updateWithTypeExpression(expression.expression, updater) : updater(expression.expression), expression.type); if (ts.isTypeAssertionExpression(expression)) return ts.factory.updateTypeAssertion(expression, expression.type, isWithTypeExpression(expression.expression) ? updateWithTypeExpression(expression.expression, updater) : updater(expression.expression)); return updater(expression); } export function isWithTypeExpression(expression) { return ts.isAsExpression(expression) || ts.isTypeAssertionExpression(expression); } //# sourceMappingURL=updateWithTypeExpression.js.map