fix(typescript): handle global namespace without modifiers (#1646)
This commit is contained in:
1 parent
5c6fd80d50
commit
575980d7f4
3 files changed
+54
-1
No files matched your search
+2
-1
@@ -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"
|
||||
}
|
||||
Reference in new issue
Block a user