fix(typescript): handle global namespace without modifiers (#1646)

This commit is contained in:
Lucas Azzola authored and Christopher Chedeau committed 2017-05-21 08:09:29 -07:00
1 parent 5c6fd80d50
commit 575980d7f4
3 files changed
+54 -1

No files matched your search

+2 -1
View File
@@ -2414,7 +2414,8 @@ function genericPrintNoParens(path, options, print, args) {
// declare global { ... }
const isGlobalDeclaration = n.name.type === "Identifier" &&
n.name.name === "global" &&
n.modifiers.some(modifier => modifier.type === "TSDeclareKeyword");
n.modifiers &&
n.modifiers.some(modifier => modifier.type === "TSDeclareKeyword");
if (!isGlobalDeclaration) {
parts.push(isExternalModule ? "module " : "namespace ");
@@ -238,6 +238,42 @@ interface C {
`;
exports[`globalIsContextualKeyword.ts 1`] = `
function a() {
let global = 1;
}
function b() {
class global {}
}
namespace global {
}
function foo(global: number) {
}
let obj = {
global: "123"
}~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function a() {
let global = 1;
}
function b() {
class global {}
}
namespace global {
}
function foo(global: number) {}
let obj = {
global: "123"
};
`;
exports[`indexSignatureWithInitializer.ts 1`] = `
// These used to be indexers, now they are computed properties
interface I {
@@ -0,0 +1,16 @@
function a() {
let global = 1;
}
function b() {
class global {}
}
namespace global {
}
function foo(global: number) {
}
let obj = {
global: "123"
}