Skip to content

Commit

Permalink
support var symbol renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
Atrue committed Jan 9, 2024
1 parent bbaa062 commit 82691b0
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/collisions-resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { verboseLog } from './logger';

const renamingSupportedSymbols: readonly ts.SymbolFlags[] = [
ts.SymbolFlags.Alias,
ts.SymbolFlags.FunctionScopedVariable,
ts.SymbolFlags.BlockScopedVariable,
ts.SymbolFlags.Class,
ts.SymbolFlags.Enum,
Expand Down
3 changes: 3 additions & 0 deletions tests/e2e/test-cases/names-collision-across-files/file1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ const TEMPLATE = 'template1';
export default TEMPLATE;

export const MergedSymbol = '';

export var Variable = 1;

export interface MergedSymbol {
test(): void
};
Expand Down
3 changes: 3 additions & 0 deletions tests/e2e/test-cases/names-collision-across-files/file2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ const TEMPLATE = 'template2';
export default TEMPLATE;

export const MergedSymbol = '';

export var Variable = '';

export interface MergedSymbol {
test(): void
};
Expand Down
2 changes: 2 additions & 0 deletions tests/e2e/test-cases/names-collision-across-files/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export {
TypeName as T1,
func as f1,
NamespaceName as NS1,
Variable as V1,

// rename these to include them into import
AnotherInterface as AI1,
Expand All @@ -24,6 +25,7 @@ export {
TypeName as T2,
func as f2,
NamespaceName as NS2,
Variable as V2,

// yes, keep these without renaming so we can check that these aren't exported with wrong names
AnotherInterface,
Expand Down
4 changes: 4 additions & 0 deletions tests/e2e/test-cases/names-collision-across-files/output.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ declare namespace ExportEqNs$1 {
}
declare const TEMPLATE = "template1";
declare const MergedSymbol = "";
declare var Variable: number;
interface MergedSymbol {
test(): void;
}
Expand All @@ -43,6 +44,7 @@ declare namespace NamespaceName {
}
declare const TEMPLATE$1 = "template2";
declare const MergedSymbol$1 = "";
declare var Variable$1: string;
interface MergedSymbol$1 {
test(): void;
}
Expand Down Expand Up @@ -93,6 +95,8 @@ export {
TEMPLATE$1 as TEMPLATE2,
TypeName as T1,
TypeName$1 as T2,
Variable as V1,
Variable$1 as V2,
anotherFunc as af1,
anotherFunc$1 as anotherFunc,
func as f1,
Expand Down

0 comments on commit 82691b0

Please sign in to comment.