From 3cd1d003c0ae54715301e3838fd1aa64ba576d4a Mon Sep 17 00:00:00 2001 From: Ika Date: Fri, 30 Nov 2018 10:12:32 +0800 Subject: [PATCH] fix(typescript): do not throw errors on bigint keyword (#5577) - fix `Error: unknown type: "TSBigIntKeyword"` - bump typescript to stable version --- package.json | 2 +- src/language-js/printer-estree.js | 2 ++ .../__snapshots__/jsfmt.spec.js.snap | 15 +++++++++++++++ tests/typescript_bigint/bigint.ts | 1 + tests/typescript_bigint/jsfmt.spec.js | 1 + yarn.lock | 19 +++---------------- 6 files changed, 23 insertions(+), 17 deletions(-) create mode 100644 tests/typescript_bigint/__snapshots__/jsfmt.spec.js.snap create mode 100644 tests/typescript_bigint/bigint.ts create mode 100644 tests/typescript_bigint/jsfmt.spec.js diff --git a/package.json b/package.json index 644cecee7534..b406a54d5b1e 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "resolve": "1.5.0", "semver": "5.4.1", "string-width": "2.1.1", - "typescript": "3.2.0-rc", + "typescript": "3.2.1", "typescript-estree": "6.0.0-rc.1", "unicode-regex": "2.0.0", "unified": "6.1.6", diff --git a/src/language-js/printer-estree.js b/src/language-js/printer-estree.js index 6a25d125eaa6..6e094890b046 100644 --- a/src/language-js/printer-estree.js +++ b/src/language-js/printer-estree.js @@ -3093,6 +3093,8 @@ function printPathNoParens(path, options, print, args) { return "async"; case "TSBooleanKeyword": return "boolean"; + case "TSBigIntKeyword": + return "bigint"; case "TSConstKeyword": return "const"; case "TSDeclareKeyword": diff --git a/tests/typescript_bigint/__snapshots__/jsfmt.spec.js.snap b/tests/typescript_bigint/__snapshots__/jsfmt.spec.js.snap new file mode 100644 index 000000000000..8351e17cc5d7 --- /dev/null +++ b/tests/typescript_bigint/__snapshots__/jsfmt.spec.js.snap @@ -0,0 +1,15 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`bigint.ts 1`] = ` +====================================options===================================== +parsers: ["typescript"] +printWidth: 80 + | printWidth +=====================================input====================================== +type T00 = bigint; + +=====================================output===================================== +type T00 = bigint; + +================================================================================ +`; diff --git a/tests/typescript_bigint/bigint.ts b/tests/typescript_bigint/bigint.ts new file mode 100644 index 000000000000..f12ed358939a --- /dev/null +++ b/tests/typescript_bigint/bigint.ts @@ -0,0 +1 @@ +type T00 = bigint; diff --git a/tests/typescript_bigint/jsfmt.spec.js b/tests/typescript_bigint/jsfmt.spec.js new file mode 100644 index 000000000000..2ea3bb6eb2e4 --- /dev/null +++ b/tests/typescript_bigint/jsfmt.spec.js @@ -0,0 +1 @@ +run_spec(__dirname, ["typescript"]); diff --git a/yarn.lock b/yarn.lock index dcd1a3184eea..8c16cc12f88c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -741,7 +741,6 @@ are-we-there-yet@~1.1.2: argparse@^1.0.7: version "1.0.10" resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911" - integrity sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg== dependencies: sprintf-js "~1.0.2" @@ -1247,7 +1246,6 @@ cache-base@^1.0.1: caller-callsite@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/caller-callsite/-/caller-callsite-2.0.0.tgz#847e0fce0a223750a9a027c54b33731ad3154134" - integrity sha1-hH4PzgoiN1CpoCfFSzNzGtMVQTQ= dependencies: callsites "^2.0.0" @@ -1260,7 +1258,6 @@ caller-path@^0.1.0: caller-path@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/caller-path/-/caller-path-2.0.0.tgz#468f83044e369ab2010fac5f06ceee15bb2cb1f4" - integrity sha1-Ro+DBE42mrIBD6xfBs7uFbsssfQ= dependencies: caller-callsite "^2.0.0" @@ -1558,7 +1555,6 @@ core-util-is@~1.0.0: cosmiconfig@5.0.7: version "5.0.7" resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-5.0.7.tgz#39826b292ee0d78eda137dfa3173bd1c21a43b04" - integrity sha512-PcLqxTKiDmNT6pSpy4N6KtuPwb53W+2tzNvwOZw0WH9N6O0vLIBq0x8aj8Oj75ere4YcGi48bDFCL+3fRJdlNA== dependencies: import-fresh "^2.0.0" is-directory "^0.3.1" @@ -1901,7 +1897,6 @@ error-ex@^1.2.0: error-ex@^1.3.1: version "1.3.2" resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.2.tgz#b4ac40648107fdcdcfae242f428bea8a14d4f1bf" - integrity sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g== dependencies: is-arrayish "^0.2.1" @@ -2138,7 +2133,6 @@ esprima@^3.1.3: esprima@^4.0.0: version "4.0.1" resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" - integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A== esquery@^1.0.0: version "1.0.0" @@ -2824,7 +2818,6 @@ ignore@3.3.7, ignore@^3.3.3, ignore@^3.3.5: import-fresh@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-2.0.0.tgz#d81355c15612d386c61f9ddd3922d4304822a546" - integrity sha1-2BNVwVYS04bGH53dOSLUMEgipUY= dependencies: caller-path "^2.0.0" resolve-from "^3.0.0" @@ -2936,7 +2929,6 @@ is-alphanumerical@^1.0.0: is-arrayish@^0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d" - integrity sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0= is-binary-path@^1.0.0: version "1.0.1" @@ -3003,7 +2995,6 @@ is-descriptor@^1.0.0, is-descriptor@^1.0.2: is-directory@^0.3.1: version "0.3.1" resolved "https://registry.yarnpkg.com/is-directory/-/is-directory-0.3.1.tgz#61339b6f2475fc772fd9c9d83f5c8575dc154ae1" - integrity sha1-YTObbyR1/Hcv2cnYP1yFddwVSuE= is-dotfile@^1.0.0: version "1.0.3" @@ -3630,7 +3621,6 @@ js-yaml@^3.7.0, js-yaml@^3.9.1: js-yaml@^3.9.0: version "3.12.0" resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.12.0.tgz#eaed656ec8344f10f527c6bfa1b6e2244de167d1" - integrity sha512-PIt2cnwmPfL4hKNwqeiuz4bKfnzHTBv6HyVgjahA6mPLwPDzjDWrplJBMjHUFxku/N3FlmrbyPclad+I+4mJ3A== dependencies: argparse "^1.0.7" esprima "^4.0.0" @@ -3693,7 +3683,6 @@ json-loader@^0.5.4: json-parse-better-errors@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz#bb867cfb3450e69107c131d1c514bab3dc8bcaa9" - integrity sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw== json-schema-traverse@^0.3.0: version "0.3.1" @@ -4428,7 +4417,6 @@ parse-json@^2.2.0: parse-json@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-4.0.0.tgz#be35f5425be1f7f6c747184f98a788cb99477ee0" - integrity sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA= dependencies: error-ex "^1.3.1" json-parse-better-errors "^1.0.1" @@ -5416,7 +5404,6 @@ split-string@^3.0.1, split-string@^3.0.2: sprintf-js@~1.0.2: version "1.0.3" resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" - integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw= sshpk@^1.7.0: version "1.13.1" @@ -5751,9 +5738,9 @@ typescript-estree@6.0.0-rc.1: lodash.unescape "4.0.1" semver "5.5.0" -typescript@3.2.0-rc: - version "3.2.0-rc" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.2.0-rc.tgz#7c3816f1c761b096f4f1712382e872f4da8f263e" +typescript@3.2.1: + version "3.2.1" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.2.1.tgz#0b7a04b8cf3868188de914d9568bd030f0c56192" ua-parser-js@^0.7.9: version "0.7.17"