Add createRegularExpressionLiteral and expose createStringLiteral

Fixes: #23992
This commit is contained in:
Klaus Meinhardt 2018-05-09 22:22:46 +02:00
parent 6f9dc2f976
commit fc3ba76ab7
3 changed files with 11 additions and 1 deletions

View File

@ -93,12 +93,18 @@ namespace ts {
return node;
}
function createStringLiteral(text: string): StringLiteral {
export function createStringLiteral(text: string): StringLiteral {
const node = <StringLiteral>createSynthesizedNode(SyntaxKind.StringLiteral);
node.text = text;
return node;
}
export function createRegularExpressionLiteral(text: string): RegularExpressionLiteral {
const node = <RegularExpressionLiteral>createSynthesizedNode(SyntaxKind.RegularExpressionLiteral);
node.text = text;
return node;
}
function createLiteralFromNode(sourceNode: PropertyNameLiteral): StringLiteral {
const node = createStringLiteral(getTextOfIdentifierOrLiteral(sourceNode));
node.textSourceNode = sourceNode;

View File

@ -3484,6 +3484,8 @@ declare namespace ts {
function createLiteral(value: boolean): BooleanLiteral;
function createLiteral(value: string | number | boolean): PrimaryExpression;
function createNumericLiteral(value: string): NumericLiteral;
function createStringLiteral(text: string): StringLiteral;
function createRegularExpressionLiteral(text: string): RegularExpressionLiteral;
function createIdentifier(text: string): Identifier;
function updateIdentifier(node: Identifier): Identifier;
/** Create a unique temporary variable. */

View File

@ -3484,6 +3484,8 @@ declare namespace ts {
function createLiteral(value: boolean): BooleanLiteral;
function createLiteral(value: string | number | boolean): PrimaryExpression;
function createNumericLiteral(value: string): NumericLiteral;
function createStringLiteral(text: string): StringLiteral;
function createRegularExpressionLiteral(text: string): RegularExpressionLiteral;
function createIdentifier(text: string): Identifier;
function updateIdentifier(node: Identifier): Identifier;
/** Create a unique temporary variable. */