From 23e0e90779df03b4b538a8aa62f939b2462c3d41 Mon Sep 17 00:00:00 2001 From: James Henry Date: Mon, 21 Aug 2017 20:27:35 +0100 Subject: [PATCH] Update tsep and account for AST differences (#2647) --- package.json | 2 +- src/printer.js | 15 +++++++++------ yarn.lock | 4 ++-- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 45970c8b..3c8a63b5 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "postcss-values-parser": "git://github.com/shellscape/postcss-values-parser.git#5e351360479116f3fe309602cdd15b0a233bc29f", "strip-bom": "3.0.0", "typescript": "2.5.0-dev.20170617", - "typescript-eslint-parser": "git://github.com/eslint/typescript-eslint-parser.git#65b019ba9a10475af30e664ce38e550c21acdedd" + "typescript-eslint-parser": "git://github.com/eslint/typescript-eslint-parser.git#01c34f44e7bb3b8a1ec3d28433a6e0c9b2901d3c" }, "devDependencies": { "babel-cli": "6.24.1", diff --git a/src/printer.js b/src/printer.js index 2e084529..d7cbcd1f 100644 --- a/src/printer.js +++ b/src/printer.js @@ -612,7 +612,7 @@ function genericPrintNoParens(path, options, print, args) { } return path.call(print, "id"); - case "TSExportAssigment": + case "TSExportAssignment": return concat(["export = ", path.call(print, "expression"), semi]); case "ExportDefaultDeclaration": case "ExportNamedDeclaration": @@ -2624,22 +2624,25 @@ function genericPrintNoParens(path, options, print, args) { return concat(["require(", path.call(print, "expression"), ")"]); case "TSModuleDeclaration": { const parent = path.getParentNode(); - const isExternalModule = isLiteral(n.name); + const isExternalModule = isLiteral(n.id); const parentIsDeclaration = parent.type === "TSModuleDeclaration"; const bodyIsDeclaration = n.body && n.body.type === "TSModuleDeclaration"; if (parentIsDeclaration) { parts.push("."); } else { + if (n.declare === true) { + parts.push("declare "); + } parts.push(printTypeScriptModifiers(path, options, print)); // Global declaration looks like this: // (declare)? global { ... } const isGlobalDeclaration = - n.name.type === "Identifier" && - n.name.name === "global" && + n.id.type === "Identifier" && + n.id.name === "global" && !/namespace|module/.test( - options.originalText.slice(util.locStart(n), util.locStart(n.name)) + options.originalText.slice(util.locStart(n), util.locStart(n.id)) ); if (!isGlobalDeclaration) { @@ -2647,7 +2650,7 @@ function genericPrintNoParens(path, options, print, args) { } } - parts.push(path.call(print, "name")); + parts.push(path.call(print, "id")); if (bodyIsDeclaration) { parts.push(path.call(print, "body")); diff --git a/yarn.lock b/yarn.lock index 5972b9d4..ec7dad87 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3808,9 +3808,9 @@ typedarray@^0.0.6: version "0.0.6" resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" -"typescript-eslint-parser@git://github.com/eslint/typescript-eslint-parser.git#65b019ba9a10475af30e664ce38e550c21acdedd": +"typescript-eslint-parser@git://github.com/eslint/typescript-eslint-parser.git#01c34f44e7bb3b8a1ec3d28433a6e0c9b2901d3c": version "6.0.1" - resolved "git://github.com/eslint/typescript-eslint-parser.git#65b019ba9a10475af30e664ce38e550c21acdedd" + resolved "git://github.com/eslint/typescript-eslint-parser.git#01c34f44e7bb3b8a1ec3d28433a6e0c9b2901d3c" dependencies: lodash.unescape "4.0.1" semver "5.3.0"