Skip to content

Commit 5f28651

Browse files
authored
fix: createLiteral removed in 5.1 microsoft/TypeScript#53077 (comment) (#1574)
* fix: createLiteral removed in 5.1 microsoft/TypeScript#53077 (comment) * fix: factory
1 parent 9aa5b52 commit 5f28651

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

test/comparison-tests/customTransformer/uppercaseStringLiteralTransformer.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ var transformer = function (context) {
66
if (node.kind === ts.SyntaxKind.StringLiteral) {
77
var text = node.text;
88
if (text !== text.toUpperCase()) {
9-
return ts.createLiteral(text.toUpperCase());
9+
// createLiteral removed in 5.1 https://github.com/microsoft/TypeScript/issues/53077#issuecomment-1453846217
10+
return ts.createLiteral ? ts.createLiteral(text.toUpperCase()) : ts.factory.createStringLiteral(text.toUpperCase());
1011
}
1112
}
1213
return ts.visitEachChild(node, visitor, context);

test/comparison-tests/customTransformerUsingPathString/uppercaseStringLiteralTransformer.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ var transformer = function (context) {
66
if (node.kind === ts.SyntaxKind.StringLiteral) {
77
var text = node.text;
88
if (text !== text.toUpperCase()) {
9-
return ts.createLiteral(text.toUpperCase());
9+
// createLiteral removed in 5.1 https://github.com/microsoft/TypeScript/issues/53077#issuecomment-1453846217
10+
return ts.createLiteral ? ts.createLiteral(text.toUpperCase()) : ts.factory.createStringLiteral(text.toUpperCase());
1011
}
1112
}
1213
return ts.visitEachChild(node, visitor, context);

test/execution-tests/loaderOptions/uppercaseStringLiteralTransformer.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ var transformer = function (context) {
77
var text = node.text;
88
if (text.match(/^Hello from submodule/) !== null) {
99
if (text !== text.toUpperCase()) {
10-
return ts.createLiteral(text.toUpperCase());
10+
// https://github.com/microsoft/TypeScript/issues/53077#issuecomment-1453846217
11+
return ts.createLiteral ? ts.createLiteral(text.toUpperCase()) : ts.factory.createStringLiteral(text.toUpperCase());
1112
}
1213
}
1314
}

0 commit comments

Comments
 (0)