Skip to content

Commit fc3ba76

Browse files
committed
Add createRegularExpressionLiteral and expose createStringLiteral
Fixes: microsoft#23992
1 parent 6f9dc2f commit fc3ba76

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

src/compiler/factory.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,18 @@ namespace ts {
9393
return node;
9494
}
9595

96-
function createStringLiteral(text: string): StringLiteral {
96+
export function createStringLiteral(text: string): StringLiteral {
9797
const node = <StringLiteral>createSynthesizedNode(SyntaxKind.StringLiteral);
9898
node.text = text;
9999
return node;
100100
}
101101

102+
export function createRegularExpressionLiteral(text: string): RegularExpressionLiteral {
103+
const node = <RegularExpressionLiteral>createSynthesizedNode(SyntaxKind.RegularExpressionLiteral);
104+
node.text = text;
105+
return node;
106+
}
107+
102108
function createLiteralFromNode(sourceNode: PropertyNameLiteral): StringLiteral {
103109
const node = createStringLiteral(getTextOfIdentifierOrLiteral(sourceNode));
104110
node.textSourceNode = sourceNode;

tests/baselines/reference/api/tsserverlibrary.d.ts

+2
Original file line numberDiff line numberDiff line change
@@ -3484,6 +3484,8 @@ declare namespace ts {
34843484
function createLiteral(value: boolean): BooleanLiteral;
34853485
function createLiteral(value: string | number | boolean): PrimaryExpression;
34863486
function createNumericLiteral(value: string): NumericLiteral;
3487+
function createStringLiteral(text: string): StringLiteral;
3488+
function createRegularExpressionLiteral(text: string): RegularExpressionLiteral;
34873489
function createIdentifier(text: string): Identifier;
34883490
function updateIdentifier(node: Identifier): Identifier;
34893491
/** Create a unique temporary variable. */

tests/baselines/reference/api/typescript.d.ts

+2
Original file line numberDiff line numberDiff line change
@@ -3484,6 +3484,8 @@ declare namespace ts {
34843484
function createLiteral(value: boolean): BooleanLiteral;
34853485
function createLiteral(value: string | number | boolean): PrimaryExpression;
34863486
function createNumericLiteral(value: string): NumericLiteral;
3487+
function createStringLiteral(text: string): StringLiteral;
3488+
function createRegularExpressionLiteral(text: string): RegularExpressionLiteral;
34873489
function createIdentifier(text: string): Identifier;
34883490
function updateIdentifier(node: Identifier): Identifier;
34893491
/** Create a unique temporary variable. */

0 commit comments

Comments
 (0)