@@ -1316,7 +1316,7 @@ let emitEnum flags overrideFunc (ctx: Context) (current: StructuredText) (e: Enu
1316
1316
|> List.map fst
1317
1317
let casesText =
1318
1318
if ( cases |> List.sumBy ( fun s -> s.Length)) > 80 then
1319
- concat newline [
1319
+ newline + concat newline [
1320
1320
for case in cases do
1321
1321
yield indent ( tprintf " | %s " case)
1322
1322
]
@@ -1354,10 +1354,12 @@ let emitEnum flags overrideFunc (ctx: Context) (current: StructuredText) (e: Enu
1354
1354
]
1355
1355
let items = items @ List.map child e.cases
1356
1356
let comments = e.comments |> emitComments
1357
- let exports = getExportFromStatement ctx e.name Kind.OfEnum " enum" ( Enum e)
1358
- {| StructuredTextNode.empty with items = items; comments = comments; exports = Option.toList exports |}
1357
+ {| StructuredTextNode.empty with items = items; comments = comments |}
1359
1358
1360
- current |> add [ e.name] parentNode
1359
+ let exports = getExportFromStatement ctx e.name Kind.OfEnum " enum" ( Enum e)
1360
+ current
1361
+ |> add [ e.name] parentNode
1362
+ |> set {| StructuredTextNode.empty with exports = Option.toList exports |}
1361
1363
1362
1364
let private createExternalForValue ( ctx : Context ) ( rename : string -> string ) ( s : CurrentScope ) attr comments name ty =
1363
1365
let fallback () =
@@ -1776,10 +1778,12 @@ let rec emitModule (flags: EmitModuleFlags) (ctx: Context) (st: StructuredText)
1776
1778
let ctx = ctx |> Context.ofChildNamespace k
1777
1779
let result = emitModule flags ctx v
1778
1780
let openTypesModule =
1779
- let hasTypeDefinitions = result.types |> List.isEmpty |> not
1780
- v.value
1781
- |> Option.map ( fun v -> hasTypeDefinitions && v.openTypesModule)
1782
- |> Option.defaultValue hasTypeDefinitions
1781
+ if flags.isReservedModule then false
1782
+ else
1783
+ let hasTypeDefinitions = result.types |> List.isEmpty |> not
1784
+ v.value
1785
+ |> Option.map ( fun v -> hasTypeDefinitions && v.openTypesModule)
1786
+ |> Option.defaultValue hasTypeDefinitions
1783
1787
{| name = name; origName = k |}, openTypesModule, result)
1784
1788
1785
1789
let items =
@@ -1856,7 +1860,7 @@ let rec emitModule (flags: EmitModuleFlags) (ctx: Context) (st: StructuredText)
1856
1860
| Choice3Of5 b -> yield ! Binding.emitForInterface b
1857
1861
| Choice5Of5 c -> yield c
1858
1862
| _ -> ()
1859
- // yield! exports.intf
1863
+ yield ! exports.intf
1860
1864
]
1861
1865
1862
1866
let impl =
@@ -1885,7 +1889,7 @@ let rec emitModule (flags: EmitModuleFlags) (ctx: Context) (st: StructuredText)
1885
1889
| Choice3Of5 b -> yield ! Binding.emitForImplementation b
1886
1890
| Choice5Of5 c -> yield c
1887
1891
| _ -> ()
1888
- // yield! exports.impl
1892
+ yield ! exports.impl
1889
1893
]
1890
1894
1891
1895
let comments =
@@ -1894,13 +1898,6 @@ let rec emitModule (flags: EmitModuleFlags) (ctx: Context) (st: StructuredText)
1894
1898
{| imports = imports; types = types; intf = intf; impl = impl; comments = comments |}
1895
1899
1896
1900
and emitExportModule ( ctx : Context ) ( exports : ExportItem list ) : EmitModuleResult =
1897
- let emitComment comments origText = [
1898
- let hasDocComment = not ( List.isEmpty comments)
1899
- yield commentStr origText |> TypeDefText
1900
- if hasDocComment then
1901
- yield comments |> emitComments |> concat newline |> comment |> TypeDefText
1902
- ]
1903
-
1904
1901
let emitModuleAlias name ( i : Ident ) =
1905
1902
if i.kind |> Option.map Kind.generatesReScriptModule |> Option.defaultValue false then
1906
1903
[ Statement.moduleAlias
@@ -1931,18 +1928,9 @@ and emitExportModule (ctx: Context) (exports: ExportItem list) : EmitModuleResul
1931
1928
| ES6Export e :: rest ->
1932
1929
let name = e.renameAs |> Option.defaultValue ( e.target.name |> List.last)
1933
1930
go' ( acc |> setItems [ " Export" ] ( emitModuleAlias name e.target)) rest
1934
- let acc =
1935
- let generatesExportModule =
1936
- clauses |> List.exists ( function ES6Export _ | ES6DefaultExport _ -> true | _ -> false )
1937
- if generatesExportModule then
1938
- acc |> setItems [ " Export" ] ( emitComment export.comments export.origText)
1939
- else
1940
- acc |> addItems ( emitComment export.comments export.origText)
1941
1931
go false ( go' acc clauses) rest
1942
1932
| ExportItem.ReExport export :: rest ->
1943
1933
// TODO
1944
- let acc =
1945
- acc |> setItems [ " Export" ] ( emitComment export.comments export.origText)
1946
1934
go isFirst acc rest
1947
1935
1948
1936
let st = go true Trie.empty exports
0 commit comments