Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions src/compiler/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ namespace ts {
return createLiteralFromNode(value);
}

export function createNumericLiteral(value: string): NumericLiteral {
export function createNumericLiteral(value: string, numericLiteralFlags: TokenFlags = TokenFlags.None): NumericLiteral {
const node = <NumericLiteral>createSynthesizedNode(SyntaxKind.NumericLiteral);
node.text = value;
node.numericLiteralFlags = 0;
node.numericLiteralFlags = numericLiteralFlags;
return node;
}

Expand Down
8 changes: 7 additions & 1 deletion src/compiler/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1648,20 +1648,26 @@ namespace ts {
kind: SyntaxKind.NoSubstitutionTemplateLiteral;
}

/* @internal */
export const enum TokenFlags {
None = 0,
/* @internal */
PrecedingLineBreak = 1 << 0,
/* @internal */
PrecedingJSDocComment = 1 << 1,
/* @internal */
Unterminated = 1 << 2,
/* @internal */
ExtendedUnicodeEscape = 1 << 3,
Scientific = 1 << 4, // e.g. `10e2`
Octal = 1 << 5, // e.g. `0777`
HexSpecifier = 1 << 6, // e.g. `0x00000000`
BinarySpecifier = 1 << 7, // e.g. `0b0110010000000000`
OctalSpecifier = 1 << 8, // e.g. `0o777`
/* @internal */
ContainsSeparator = 1 << 9, // e.g. `0b1100_0101`
/* @internal */
BinaryOrOctalSpecifier = BinarySpecifier | OctalSpecifier,
/* @internal */
NumericLiteralFlags = Scientific | Octal | HexSpecifier | BinaryOrOctalSpecifier | ContainsSeparator
}

Expand Down
10 changes: 9 additions & 1 deletion tests/baselines/reference/api/tsserverlibrary.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -997,6 +997,14 @@ declare namespace ts {
interface NoSubstitutionTemplateLiteral extends LiteralExpression {
kind: SyntaxKind.NoSubstitutionTemplateLiteral;
}
enum TokenFlags {
None = 0,
Scientific = 16,
Octal = 32,
HexSpecifier = 64,
BinarySpecifier = 128,
OctalSpecifier = 256
}
interface NumericLiteral extends LiteralExpression {
kind: SyntaxKind.NumericLiteral;
}
Expand Down Expand Up @@ -3670,7 +3678,7 @@ declare namespace ts {
function createLiteral(value: number | PseudoBigInt): NumericLiteral;
function createLiteral(value: boolean): BooleanLiteral;
function createLiteral(value: string | number | PseudoBigInt | boolean): PrimaryExpression;
function createNumericLiteral(value: string): NumericLiteral;
function createNumericLiteral(value: string, numericLiteralFlags?: TokenFlags): NumericLiteral;
function createBigIntLiteral(value: string): BigIntLiteral;
function createStringLiteral(text: string): StringLiteral;
function createRegularExpressionLiteral(text: string): RegularExpressionLiteral;
Expand Down
10 changes: 9 additions & 1 deletion tests/baselines/reference/api/typescript.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -997,6 +997,14 @@ declare namespace ts {
interface NoSubstitutionTemplateLiteral extends LiteralExpression {
kind: SyntaxKind.NoSubstitutionTemplateLiteral;
}
enum TokenFlags {
None = 0,
Scientific = 16,
Octal = 32,
HexSpecifier = 64,
BinarySpecifier = 128,
OctalSpecifier = 256
}
interface NumericLiteral extends LiteralExpression {
kind: SyntaxKind.NumericLiteral;
}
Expand Down Expand Up @@ -3670,7 +3678,7 @@ declare namespace ts {
function createLiteral(value: number | PseudoBigInt): NumericLiteral;
function createLiteral(value: boolean): BooleanLiteral;
function createLiteral(value: string | number | PseudoBigInt | boolean): PrimaryExpression;
function createNumericLiteral(value: string): NumericLiteral;
function createNumericLiteral(value: string, numericLiteralFlags?: TokenFlags): NumericLiteral;
function createBigIntLiteral(value: string): BigIntLiteral;
function createStringLiteral(text: string): StringLiteral;
function createRegularExpressionLiteral(text: string): RegularExpressionLiteral;
Expand Down