From 30c443da7a5577f66ff4636ddaf9094be4da2ed1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 16 Mar 2021 18:07:48 +0000 Subject: [PATCH 1/2] Build(deps): Bump @babel/parser from 7.13.10 to 7.13.11 Bumps [@babel/parser](https://github.com/babel/babel/tree/HEAD/packages/babel-parser) from 7.13.10 to 7.13.11. - [Release notes](https://github.com/babel/babel/releases) - [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md) - [Commits](https://github.com/babel/babel/commits/v7.13.11/packages/babel-parser) Signed-off-by: dependabot[bot] --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 44e7c681d107..c218ce019aef 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "dependencies": { "@angular/compiler": "11.2.5", "@babel/code-frame": "7.12.13", - "@babel/parser": "7.13.10", + "@babel/parser": "7.13.11", "@glimmer/syntax": "0.77.2", "@iarna/toml": "2.2.5", "@typescript-eslint/typescript-estree": "4.16.1", diff --git a/yarn.lock b/yarn.lock index 39862c75f121..d2a83b0be648 100644 --- a/yarn.lock +++ b/yarn.lock @@ -283,10 +283,10 @@ chalk "^2.0.0" js-tokens "^4.0.0" -"@babel/parser@7.13.10", "@babel/parser@^7.1.0", "@babel/parser@^7.12.13", "@babel/parser@^7.13.0", "@babel/parser@^7.13.10": - version "7.13.10" - resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.13.10.tgz#8f8f9bf7b3afa3eabd061f7a5bcdf4fec3c48409" - integrity sha512-0s7Mlrw9uTWkYua7xWr99Wpk2bnGa0ANleKfksYAES8LpWH4gW1OUr42vqKNf0us5UQNfru2wPqMqRITzq/SIQ== +"@babel/parser@7.13.11", "@babel/parser@^7.1.0", "@babel/parser@^7.12.13", "@babel/parser@^7.13.0", "@babel/parser@^7.13.10": + version "7.13.11" + resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.13.11.tgz#f93ebfc99d21c1772afbbaa153f47e7ce2f50b88" + integrity sha512-PhuoqeHoO9fc4ffMEVk4qb/w/s2iOSWohvbHxLtxui0eBg3Lg5gN1U8wp1V1u61hOWkPQJJyJzGH6Y+grwkq8Q== "@babel/plugin-proposal-async-generator-functions@^7.13.8": version "7.13.8" From 7039d3ef1f17ee5b526483ec9c5425b47d3653ac Mon Sep 17 00:00:00 2001 From: sosukesuzuki Date: Sun, 21 Mar 2021 22:51:21 +0900 Subject: [PATCH 2/2] Format type imports in TSImportEqualsDeclaration --- src/language-js/print/typescript.js | 8 +++- .../__snapshots__/jsfmt.spec.js.snap | 40 +++++++++++++++++++ .../type-import-equals-declaration.ts | 18 +++++++++ 3 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 tests/misc/typescript-babel-only/type-import-equals-declaration.ts diff --git a/src/language-js/print/typescript.js b/src/language-js/print/typescript.js index 9a71c934a8af..c49a818e97c7 100644 --- a/src/language-js/print/typescript.js +++ b/src/language-js/print/typescript.js @@ -457,8 +457,14 @@ function printTypescript(path, options, print) { if (node.isExport) { parts.push("export "); } + + parts.push("import "); + + if (node.importKind && node.importKind !== "value") { + parts.push(node.importKind, " "); + } + parts.push( - "import ", path.call(print, "id"), " = ", path.call(print, "moduleReference") diff --git a/tests/misc/typescript-babel-only/__snapshots__/jsfmt.spec.js.snap b/tests/misc/typescript-babel-only/__snapshots__/jsfmt.spec.js.snap index 45f2edd1376c..61aa2f761a7e 100644 --- a/tests/misc/typescript-babel-only/__snapshots__/jsfmt.spec.js.snap +++ b/tests/misc/typescript-babel-only/__snapshots__/jsfmt.spec.js.snap @@ -81,3 +81,43 @@ type T = [x: A]; ================================================================================ `; + +exports[`type-import-equals-declaration.ts format 1`] = ` +====================================options===================================== +parsers: ["babel-ts"] +printWidth: 80 + | printWidth +=====================================input====================================== +import type A = require("foo"); +export import type = require("A"); + +import type +A = require("A"); + +import +type +a = require("a"); + +export import +type +B = require("B"); + +export +import +type +b = require("b"); + +=====================================output===================================== +import type A = require("foo"); +export import type = require("A"); + +import type A = require("A"); + +import type a = require("a"); + +export import type B = require("B"); + +export import type b = require("b"); + +================================================================================ +`; diff --git a/tests/misc/typescript-babel-only/type-import-equals-declaration.ts b/tests/misc/typescript-babel-only/type-import-equals-declaration.ts new file mode 100644 index 000000000000..acdf20f77610 --- /dev/null +++ b/tests/misc/typescript-babel-only/type-import-equals-declaration.ts @@ -0,0 +1,18 @@ +import type A = require("foo"); +export import type = require("A"); + +import type +A = require("A"); + +import +type +a = require("a"); + +export import +type +B = require("B"); + +export +import +type +b = require("b");