Skip to content

Commit c920bb3

Browse files
hazzard993Perryvw
authored andcommitted
Stop prefixing identifiers from global augs (#804)
* Stop prefixing identifiers from global augs * Check for GlobalAug inside getSymbolExportScope
1 parent 722268d commit c920bb3

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

src/transformation/utils/export.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ export function getIdentifierExportScope(
4747
return getSymbolExportScope(context, symbol);
4848
}
4949

50+
function isGlobalAugmentation(module: ts.ModuleDeclaration): boolean {
51+
return (module.flags & ts.NodeFlags.GlobalAugmentation) !== 0;
52+
}
53+
5054
export function getSymbolExportScope(
5155
context: TransformationContext,
5256
symbol: ts.Symbol
@@ -64,6 +68,10 @@ export function getSymbolExportScope(
6468
return undefined;
6569
}
6670

71+
if (ts.isModuleDeclaration(scope) && isGlobalAugmentation(scope)) {
72+
return undefined;
73+
}
74+
6775
if (!isSymbolExportedFromScope(context, symbol, scope)) {
6876
return undefined;
6977
}

test/translation/__snapshots__/transformation.spec.ts.snap

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ end
8282
return ____exports"
8383
`;
8484

85+
exports[`Transformation (globalAugmentation) 1`] = `
86+
"local ____exports = globalVariable
87+
return ____exports"
88+
`;
89+
8590
exports[`Transformation (methodRestArguments) 1`] = `
8691
"require(\\"lualib_bundle\\");
8792
MyClass = __TS__Class()
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
declare global {
2+
export const globalVariable: number;
3+
}
4+
5+
export = globalVariable;

0 commit comments

Comments
 (0)