File tree Expand file tree Collapse file tree 3 files changed +25
-2
lines changed
src/transformation/visitors Expand file tree Collapse file tree 3 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import * as ts from "typescript";
22import * as lua from "../../LuaAST" ;
33import { FunctionVisitor , TransformationContext } from "../context" ;
44import { AnnotationKind , getTypeAnnotations } from "../utils/annotations" ;
5- import { getSymbolExportScope } from "../utils/export" ;
5+ import { addExportToIdentifier , getSymbolExportScope } from "../utils/export" ;
66import { createLocalOrExportedOrGlobalDeclaration } from "../utils/lua-ast" ;
77import { isFirstDeclaration } from "../utils/typescript" ;
88import { transformIdentifier } from "./identifier" ;
@@ -32,7 +32,7 @@ export const transformEnumDeclaration: FunctionVisitor<ts.EnumDeclaration> = (no
3232 if ( ! membersOnly && isFirstDeclaration ( context , node ) ) {
3333 const name = transformIdentifier ( context , node . name ) ;
3434 const table = lua . createBinaryExpression (
35- lua . cloneIdentifier ( name ) ,
35+ addExportToIdentifier ( context , name ) ,
3636 lua . createTableExpression ( ) ,
3737 lua . SyntaxKind . OrOperator
3838 ) ;
Original file line number Diff line number Diff line change 1+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+ exports [` enum nested in namespace 1` ] = `
4+ "A = A or ({ } )
5+ do
6+ A.TestEnum = A.TestEnum or ({ } )
7+ A.TestEnum.B = 0
8+ A.TestEnum[A.TestEnum.B] = "B"
9+ A.TestEnum.C = 1
10+ A.TestEnum[A.TestEnum.C] = "C"
11+ end"
12+ ` ;
Original file line number Diff line number Diff line change @@ -203,3 +203,14 @@ test("enum merging multiple files", () => {
203203 )
204204 . expectToMatchJsResult ( ) ;
205205} ) ;
206+
207+ test ( "enum nested in namespace" , ( ) => {
208+ util . testModule `
209+ namespace A {
210+ export enum TestEnum {
211+ B,
212+ C
213+ }
214+ }
215+ ` . expectLuaToMatchSnapshot ( ) ;
216+ } ) ;
You can’t perform that action at this time.
0 commit comments