fix(typescript): don't add namespace keyword to global declaration, fixes #2327 (#2329)

This commit is contained in:
Lucas Azzola authored and Christopher Chedeau committed 2017-06-28 07:53:10 -07:00
1 parent 5db9407d78
commit 678964b8de
4 files changed
+29 -3

No files matched your search

View File
Whitespace-only changes.
+4 -3
View File
@@ -2588,12 +2588,13 @@ function genericPrintNoParens(path, options, print, args) {
parts.push(printTypeScriptModifiers(path, options, print));
// Global declaration looks like this:
// declare global { ... }
// (declare)? global { ... }
const isGlobalDeclaration =
n.name.type === "Identifier" &&
n.name.name === "global" &&
n.modifiers &&
n.modifiers.some(modifier => modifier.type === "TSDeclareKeyword");
!/namespace|module/.test(
options.originalText.slice(util.locStart(n), util.locStart(n.name))
);
if (!isGlobalDeclaration) {
parts.push(isExternalModule ? "module " : "namespace ");
@@ -6,3 +6,24 @@ declare module 'autoprefixer';
declare module "autoprefixer";
`;
exports[`global.js 1`] = `
namespace global {}
module global {}
global {}
declare global {}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
namespace global {
}
namespace global {
}
global {
}
declare global {
}
`;
+4
View File
@@ -0,0 +1,4 @@
namespace global {}
module global {}
global {}
declare global {}