From ebc99877fd8abe31d7579128bb170fe41e68aa08 Mon Sep 17 00:00:00 2001 From: Ika Date: Mon, 6 Aug 2018 09:08:02 +0800 Subject: [PATCH 1/7] test: add tests --- .../__snapshots__/jsfmt.spec.js.snap | 8 ++++++++ tests/typescript_import_type/import-type.ts | 2 ++ 2 files changed, 10 insertions(+) diff --git a/tests/typescript_import_type/__snapshots__/jsfmt.spec.js.snap b/tests/typescript_import_type/__snapshots__/jsfmt.spec.js.snap index 2781bf5bd81a..62934b31acef 100644 --- a/tests/typescript_import_type/__snapshots__/jsfmt.spec.js.snap +++ b/tests/typescript_import_type/__snapshots__/jsfmt.spec.js.snap @@ -14,6 +14,8 @@ export let shim: typeof import("./foo2") = { export interface Foo { bar: import('immutable').Map; } + +type X = A>; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ref: https://github.com/Microsoft/TypeScript/pull/22592 @@ -29,6 +31,8 @@ export interface Foo { bar: import("immutable").Map; } +type X = A>; + `; exports[`import-type.ts - typescript-verify 2`] = ` @@ -45,6 +49,8 @@ export let shim: typeof import("./foo2") = { export interface Foo { bar: import('immutable').Map; } + +type X = A>; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ref: https://github.com/Microsoft/TypeScript/pull/22592 @@ -60,4 +66,6 @@ export interface Foo { bar: import('immutable').Map; } +type X = A>; + `; diff --git a/tests/typescript_import_type/import-type.ts b/tests/typescript_import_type/import-type.ts index d3c6db519282..b5291f66e6b2 100644 --- a/tests/typescript_import_type/import-type.ts +++ b/tests/typescript_import_type/import-type.ts @@ -11,3 +11,5 @@ export let shim: typeof import("./foo2") = { export interface Foo { bar: import('immutable').Map; } + +type X = A>; From 0aab0d52f5539b896ab4cae5fdf36952b3841f11 Mon Sep 17 00:00:00 2001 From: Ika Date: Mon, 6 Aug 2018 09:10:13 +0800 Subject: [PATCH 2/7] fix(typescript): no invalid output for ImportType in TypeReference --- package.json | 2 +- src/language-js/printer-estree.js | 4 ++-- .../typescript_import_type/__snapshots__/jsfmt.spec.js.snap | 4 ++-- yarn.lock | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 367ba18d8b58..837e4d625da9 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "semver": "5.4.1", "string-width": "2.1.1", "typescript": "3.0.0-dev.20180626", - "typescript-eslint-parser": "17.0.0", + "typescript-eslint-parser": "ikatyang/typescript-eslint-parser#504a576277b744ba31f293db5453bca9fe0e2cb4", "unicode-regex": "1.0.1", "unified": "6.1.6", "yaml": "ikatyang/yaml#a765c1ee16d6b8a5e715564645f2b85f7e04828b", diff --git a/src/language-js/printer-estree.js b/src/language-js/printer-estree.js index 82905116b97f..80501f066567 100644 --- a/src/language-js/printer-estree.js +++ b/src/language-js/printer-estree.js @@ -2923,11 +2923,11 @@ function printPathNoParens(path, options, print, args) { return concat([path.call(print, "expression"), "!"]); case "TSThisType": return "this"; - case "TSLastTypeNode": // TSImportType + case "TSImportType": return concat([ !n.isTypeOf ? "" : "typeof ", "import(", - path.call(print, "argument"), + path.call(print, "parameter"), ")", !n.qualifier ? "" : concat([".", path.call(print, "qualifier")]), printTypeParameters(path, options, print, "typeParameters") diff --git a/tests/typescript_import_type/__snapshots__/jsfmt.spec.js.snap b/tests/typescript_import_type/__snapshots__/jsfmt.spec.js.snap index 62934b31acef..c8819bb956f5 100644 --- a/tests/typescript_import_type/__snapshots__/jsfmt.spec.js.snap +++ b/tests/typescript_import_type/__snapshots__/jsfmt.spec.js.snap @@ -31,7 +31,7 @@ export interface Foo { bar: import("immutable").Map; } -type X = A>; +type X = A>; `; @@ -66,6 +66,6 @@ export interface Foo { bar: import('immutable').Map; } -type X = A>; +type X = A>; `; diff --git a/yarn.lock b/yarn.lock index 1fe5f1562c49..f2581220d796 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5680,9 +5680,9 @@ typedarray@^0.0.6: version "0.0.6" resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" -typescript-eslint-parser@17.0.0: - version "17.0.0" - resolved "https://registry.yarnpkg.com/typescript-eslint-parser/-/typescript-eslint-parser-17.0.0.tgz#0e2b5c0d15f2e2cfdf43dd024c96b10d016bef26" +typescript-eslint-parser@ikatyang/typescript-eslint-parser#504a576277b744ba31f293db5453bca9fe0e2cb4: + version "17.0.1" + resolved "https://codeload.github.com/ikatyang/typescript-eslint-parser/tar.gz/504a576277b744ba31f293db5453bca9fe0e2cb4" dependencies: lodash.unescape "4.0.1" semver "5.5.0" From 5fb7f3110b5f4760c2da8d014c27193ac2701ba2 Mon Sep 17 00:00:00 2001 From: Ika Date: Tue, 7 Aug 2018 07:32:15 +0800 Subject: [PATCH 3/7] chore: update parser --- package.json | 4 ++-- yarn.lock | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 837e4d625da9..5961e7b2736d 100644 --- a/package.json +++ b/package.json @@ -57,8 +57,8 @@ "resolve": "1.5.0", "semver": "5.4.1", "string-width": "2.1.1", - "typescript": "3.0.0-dev.20180626", - "typescript-eslint-parser": "ikatyang/typescript-eslint-parser#504a576277b744ba31f293db5453bca9fe0e2cb4", + "typescript": "3.0.1", + "typescript-eslint-parser": "18.0.0", "unicode-regex": "1.0.1", "unified": "6.1.6", "yaml": "ikatyang/yaml#a765c1ee16d6b8a5e715564645f2b85f7e04828b", diff --git a/yarn.lock b/yarn.lock index f2581220d796..dc602016377a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5680,16 +5680,16 @@ typedarray@^0.0.6: version "0.0.6" resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" -typescript-eslint-parser@ikatyang/typescript-eslint-parser#504a576277b744ba31f293db5453bca9fe0e2cb4: - version "17.0.1" - resolved "https://codeload.github.com/ikatyang/typescript-eslint-parser/tar.gz/504a576277b744ba31f293db5453bca9fe0e2cb4" +typescript-eslint-parser@18.0.0: + version "18.0.0" + resolved "https://registry.yarnpkg.com/typescript-eslint-parser/-/typescript-eslint-parser-18.0.0.tgz#3e5055a44980d69e4154350fc5d8b1ab4e2332a8" dependencies: lodash.unescape "4.0.1" semver "5.5.0" -typescript@3.0.0-dev.20180626: - version "3.0.0-dev.20180626" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.0.0-dev.20180626.tgz#fb6be91cfc8e8757d551e83af208d0083be61499" +typescript@3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.0.1.tgz#43738f29585d3a87575520a4b93ab6026ef11fdb" ua-parser-js@^0.7.9: version "0.7.17" From 04f508e8ade5fa65013ced86ffbe9c33c56f7fb3 Mon Sep 17 00:00:00 2001 From: Ika Date: Tue, 7 Aug 2018 07:49:48 +0800 Subject: [PATCH 4/7] chore: trigger circleci From 1b7aa67cf838dae01861691c3764d67f3e910661 Mon Sep 17 00:00:00 2001 From: Ika Date: Tue, 7 Aug 2018 08:18:32 +0800 Subject: [PATCH 5/7] chore(build): --max-old-space-size=2048 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5961e7b2736d..b22ba4eceb1e 100644 --- a/package.json +++ b/package.json @@ -117,7 +117,7 @@ "perf-benchmark": "yarn && yarn build && cross-env NODE_ENV=production node ./dist/bin-prettier.js --debug-benchmark --loglevel debug ${PERF_FILE:-./index.js} > /dev/null", "lint": "cross-env EFF_NO_LINK_RULES=true eslint . --format node_modules/eslint-friendly-formatter", "lint-docs": "prettylint {.,docs,website,website/blog}/*.md", - "build": "node ./scripts/build/build.js", + "build": "node --max-old-space-size=2048 ./scripts/build/build.js", "build-docs": "node ./scripts/build-docs.js", "check-deps": "node ./scripts/check-deps.js" } From 53781471e7e58045e317acbf54753b15320c8dd3 Mon Sep 17 00:00:00 2001 From: Ika Date: Tue, 7 Aug 2018 13:51:47 +0800 Subject: [PATCH 6/7] chore(build-docs): use yarn build --- scripts/build-docs.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/build-docs.js b/scripts/build-docs.js index e3503b7495ea..b1c99211efdf 100644 --- a/scripts/build-docs.js +++ b/scripts/build-docs.js @@ -22,7 +22,7 @@ if (isPullRequest) { const pkg = require("../package.json"); pkg.version = `999.999.999-pr.${process.env.REVIEW_ID}`; pipe(JSON.stringify(pkg, null, 2)).to("package.json"); - shell.exec("node scripts/build/build.js"); + shell.exec("yarn build"); } shell.exec(`cp ${prettierPath}/standalone.js ${docs}/`); shell.exec(`cp ${prettierPath}/parser-*.js ${docs}/`); From fe8b9078a594286582503c5d6cbc1f0048f17a15 Mon Sep 17 00:00:00 2001 From: Ika Date: Tue, 7 Aug 2018 16:17:19 +0800 Subject: [PATCH 7/7] chore(build-docs): die on errors --- scripts/build-docs.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/build-docs.js b/scripts/build-docs.js index b1c99211efdf..00b7853b02fb 100644 --- a/scripts/build-docs.js +++ b/scripts/build-docs.js @@ -5,6 +5,8 @@ const path = require("path"); const shell = require("shelljs"); +shell.config.fatal = true; + const rootDir = path.join(__dirname, ".."); const docs = path.join(rootDir, "website/static/lib");