Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace Use of Deprecated APIs #123

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions packages/transforms-ts/src/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ export type TransformResult = ts.StringLiteral | ts.ArrayLiteralExpression | ts.
export function transform(node: common.Node, context: VisitSourceFileContext | undefined): TransformResult {
switch (node.kind) {
case "StringLiteral":
return ts.createLiteral(node.value);
return ts.factory.createStringLiteral(node.value);
case "ArrayLiteral":
return ts.createArrayLiteral(node.elements.map(element => transform(element, context)));
return ts.factory.createArrayLiteralExpression(node.elements.map(element => transform(element, context)));
case "TemplateExpression":
if (node.parts.length === 1 && typeof node.parts[0] === "string") {
return ts.createNoSubstitutionTemplateLiteral(node.parts[0] as string);
return ts.factory.createNoSubstitutionTemplateLiteral(node.parts[0] as string);
}
return createTemplateExpression(node, context);
default:
Expand All @@ -32,7 +32,7 @@ function createTemplateExpression(node: common.TemplateExpressionNode, context:
const firstPart = typeof node.parts[0] === "string" ? node.parts[0] as string : undefined;
const parts = firstPart != null ? node.parts.slice(1) : [...node.parts];

return ts.createTemplateExpression(ts.createTemplateHead(firstPart || ""), getParts());
return ts.factory.createTemplateExpression(ts.factory.createTemplateHead(firstPart || ""), getParts());

function getParts() {
const templateSpans: ts.TemplateSpan[] = [];
Expand All @@ -48,14 +48,14 @@ function createTemplateExpression(node: common.TemplateExpressionNode, context:
}

const tsExpression = interpolatedNode.expression as ts.Expression;
const tsText = !isLast ? ts.createTemplateMiddle(text) : ts.createTemplateTail(text);
const tsText = !isLast ? ts.factory.createTemplateMiddle(text) : ts.factory.createTemplateTail(text);

// mark this nameof.interpolate expression as being handled
if (context != null) {
context.interpolateExpressions.delete(tsExpression);
}

templateSpans.push(ts.createTemplateSpan(tsExpression, tsText));
templateSpans.push(ts.factory.createTemplateSpan(tsExpression, tsText));
}
return templateSpans;
}
Expand Down