From b5177ce2904640f94c3ef803fb89673224ad5b78 Mon Sep 17 00:00:00 2001 From: Armano Date: Sun, 23 Dec 2018 00:18:32 +0100 Subject: [PATCH] babel-parser: typescript: add missing bigint keyword (#9230) --- .../babel-parser/src/plugins/typescript.js | 2 + packages/babel-parser/src/types.js | 1 + .../typescript/types/keywords/input.js | 1 + .../typescript/types/keywords/output.json | 93 +++++++++++++++++-- 4 files changed, 91 insertions(+), 6 deletions(-) diff --git a/packages/babel-parser/src/plugins/typescript.js b/packages/babel-parser/src/plugins/typescript.js index 95f8e61d02e9..c3c72d8139b0 100644 --- a/packages/babel-parser/src/plugins/typescript.js +++ b/packages/babel-parser/src/plugins/typescript.js @@ -45,6 +45,8 @@ function keywordTypeFromName( return "TSAnyKeyword"; case "boolean": return "TSBooleanKeyword"; + case "bigint": + return "TSBigIntKeyword"; case "never": return "TSNeverKeyword"; case "number": diff --git a/packages/babel-parser/src/types.js b/packages/babel-parser/src/types.js index 7becea9d47b9..12cf06048c6e 100644 --- a/packages/babel-parser/src/types.js +++ b/packages/babel-parser/src/types.js @@ -1157,6 +1157,7 @@ export type TsKeywordTypeType = | "TSNumberKeyword" | "TSObjectKeyword" | "TSBooleanKeyword" + | "TSBigIntKeyword" | "TSStringKeyword" | "TSSymbolKeyword" | "TSVoidKeyword" diff --git a/packages/babel-parser/test/fixtures/typescript/types/keywords/input.js b/packages/babel-parser/test/fixtures/typescript/types/keywords/input.js index 0fec8f608a1c..e75b629a04cd 100644 --- a/packages/babel-parser/test/fixtures/typescript/types/keywords/input.js +++ b/packages/babel-parser/test/fixtures/typescript/types/keywords/input.js @@ -9,3 +9,4 @@ let st: string; let sy: symbol; let u: undefined; let v: void; +let n: bigint; diff --git a/packages/babel-parser/test/fixtures/typescript/types/keywords/output.json b/packages/babel-parser/test/fixtures/typescript/types/keywords/output.json index b223120ab536..4c6e48290b18 100644 --- a/packages/babel-parser/test/fixtures/typescript/types/keywords/output.json +++ b/packages/babel-parser/test/fixtures/typescript/types/keywords/output.json @@ -1,29 +1,29 @@ { "type": "File", "start": 0, - "end": 169, + "end": 184, "loc": { "start": { "line": 1, "column": 0 }, "end": { - "line": 11, - "column": 12 + "line": 12, + "column": 14 } }, "program": { "type": "Program", "start": 0, - "end": 169, + "end": 184, "loc": { "start": { "line": 1, "column": 0 }, "end": { - "line": 11, - "column": 12 + "line": 12, + "column": 14 } }, "sourceType": "module", @@ -919,6 +919,87 @@ } ], "kind": "let" + }, + { + "type": "VariableDeclaration", + "start": 170, + "end": 184, + "loc": { + "start": { + "line": 12, + "column": 0 + }, + "end": { + "line": 12, + "column": 14 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 174, + "end": 183, + "loc": { + "start": { + "line": 12, + "column": 4 + }, + "end": { + "line": 12, + "column": 13 + } + }, + "id": { + "type": "Identifier", + "start": 174, + "end": 183, + "loc": { + "start": { + "line": 12, + "column": 4 + }, + "end": { + "line": 12, + "column": 13 + }, + "identifierName": "n" + }, + "name": "n", + "typeAnnotation": { + "type": "TSTypeAnnotation", + "start": 175, + "end": 183, + "loc": { + "start": { + "line": 12, + "column": 5 + }, + "end": { + "line": 12, + "column": 13 + } + }, + "typeAnnotation": { + "type": "TSBigIntKeyword", + "start": 177, + "end": 183, + "loc": { + "start": { + "line": 12, + "column": 7 + }, + "end": { + "line": 12, + "column": 13 + } + } + } + } + }, + "init": null + } + ], + "kind": "let" } ], "directives": []