diff --git a/packages/ast-spec/src/token/NumericToken/fixtures/bigint-literal/fixture.ts b/packages/ast-spec/src/token/NumericToken/fixtures/bigint-literal/fixture.ts new file mode 100644 index 000000000000..81f1ab850364 --- /dev/null +++ b/packages/ast-spec/src/token/NumericToken/fixtures/bigint-literal/fixture.ts @@ -0,0 +1 @@ +0n; diff --git a/packages/ast-spec/src/token/NumericToken/fixtures/bigint-literal/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/token/NumericToken/fixtures/bigint-literal/snapshots/1-TSESTree-AST.shot new file mode 100644 index 000000000000..1c0ae4724a73 --- /dev/null +++ b/packages/ast-spec/src/token/NumericToken/fixtures/bigint-literal/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,37 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures token NumericToken bigint-literal TSESTree - AST 1`] = ` +Program { + type: "Program", + body: [ + ExpressionStatement { + type: "ExpressionStatement", + expression: Literal { + type: "Literal", + bigint: "0", + raw: "0n", + value: 0n, + + range: [0, 2], + loc: { + start: { column: 0, line: 1 }, + end: { column: 2, line: 1 }, + }, + }, + + range: [0, 3], + loc: { + start: { column: 0, line: 1 }, + end: { column: 3, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 4], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/token/NumericToken/fixtures/bigint-literal/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/token/NumericToken/fixtures/bigint-literal/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 000000000000..4afe54e6c6e4 --- /dev/null +++ b/packages/ast-spec/src/token/NumericToken/fixtures/bigint-literal/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,26 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures token NumericToken bigint-literal TSESTree - Tokens 1`] = ` +[ + Numeric { + type: "Numeric", + value: "0n", + + range: [0, 2], + loc: { + start: { column: 0, line: 1 }, + end: { column: 2, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [2, 3], + loc: { + start: { column: 2, line: 1 }, + end: { column: 3, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/token/NumericToken/fixtures/bigint-literal/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/token/NumericToken/fixtures/bigint-literal/snapshots/3-Babel-AST.shot new file mode 100644 index 000000000000..e19537c7d18f --- /dev/null +++ b/packages/ast-spec/src/token/NumericToken/fixtures/bigint-literal/snapshots/3-Babel-AST.shot @@ -0,0 +1,37 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures token NumericToken bigint-literal Babel - AST 1`] = ` +Program { + type: "Program", + body: [ + ExpressionStatement { + type: "ExpressionStatement", + expression: Literal { + type: "Literal", + bigint: "0", + raw: "0n", + value: 0n, + + range: [0, 2], + loc: { + start: { column: 0, line: 1 }, + end: { column: 2, line: 1 }, + }, + }, + + range: [0, 3], + loc: { + start: { column: 0, line: 1 }, + end: { column: 3, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 4], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/token/NumericToken/fixtures/bigint-literal/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/token/NumericToken/fixtures/bigint-literal/snapshots/4-Babel-Tokens.shot new file mode 100644 index 000000000000..2e7591057743 --- /dev/null +++ b/packages/ast-spec/src/token/NumericToken/fixtures/bigint-literal/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,26 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures token NumericToken bigint-literal Babel - Tokens 1`] = ` +[ + Numeric { + type: "Numeric", + value: "0n", + + range: [0, 2], + loc: { + start: { column: 0, line: 1 }, + end: { column: 2, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [2, 3], + loc: { + start: { column: 2, line: 1 }, + end: { column: 3, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/token/NumericToken/fixtures/bigint-literal/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/token/NumericToken/fixtures/bigint-literal/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 000000000000..baf728dfc5c9 --- /dev/null +++ b/packages/ast-spec/src/token/NumericToken/fixtures/bigint-literal/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures token NumericToken bigint-literal AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/token/NumericToken/fixtures/bigint-literal/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/token/NumericToken/fixtures/bigint-literal/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 000000000000..0caee1dd5698 --- /dev/null +++ b/packages/ast-spec/src/token/NumericToken/fixtures/bigint-literal/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures token NumericToken bigint-literal AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/typescript-estree/src/node-utils.ts b/packages/typescript-estree/src/node-utils.ts index 943ee4c95079..1e67e19ed6c0 100644 --- a/packages/typescript-estree/src/node-utils.ts +++ b/packages/typescript-estree/src/node-utils.ts @@ -527,6 +527,7 @@ export function getTokenType( switch (token.kind) { case SyntaxKind.NumericLiteral: + case SyntaxKind.BigIntLiteral: return AST_TOKEN_TYPES.Numeric; case SyntaxKind.JsxText: