• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1//// [exportImportCanSubstituteConstEnumForValue.ts]
2module MsPortalFx.ViewModels.Dialogs {
3
4    export const enum DialogResult {
5        Abort,
6        Cancel,
7        Ignore,
8        No,
9        Ok,
10        Retry,
11        Yes,
12    }
13
14    export interface DialogResultCallback {
15        (result: MsPortalFx.ViewModels.Dialogs.DialogResult): void;
16    }
17
18    export function someExportedFunction() {
19    }
20
21    export const enum MessageBoxButtons {
22        AbortRetryIgnore,
23        OK,
24        OKCancel,
25        RetryCancel,
26        YesNo,
27        YesNoCancel,
28    }
29}
30
31
32module MsPortalFx.ViewModels {
33
34    /**
35     * For some reason javascript code is emitted for this re-exported const enum.
36     */
37    export import ReExportedEnum = Dialogs.DialogResult;
38
39    /**
40     * Not exported to show difference. No javascript is emmitted (as expected)
41     */
42    import DialogButtons = Dialogs.MessageBoxButtons;
43
44    /**
45     * Re-exporting a function type to show difference. No javascript is emmitted (as expected)
46     */
47    export import Callback = Dialogs.DialogResultCallback;
48
49    export class SomeUsagesOfTheseConsts {
50        constructor() {
51            // these do get replaced by the const value
52            const value1 = ReExportedEnum.Cancel;
53            console.log(value1);
54            const value2 = DialogButtons.OKCancel;
55            console.log(value2);
56        }
57    }
58}
59
60
61//// [exportImportCanSubstituteConstEnumForValue.js]
62var MsPortalFx;
63(function (MsPortalFx) {
64    var ViewModels;
65    (function (ViewModels) {
66        var Dialogs;
67        (function (Dialogs) {
68            function someExportedFunction() {
69            }
70            Dialogs.someExportedFunction = someExportedFunction;
71        })(Dialogs = ViewModels.Dialogs || (ViewModels.Dialogs = {}));
72    })(ViewModels = MsPortalFx.ViewModels || (MsPortalFx.ViewModels = {}));
73})(MsPortalFx || (MsPortalFx = {}));
74(function (MsPortalFx) {
75    var ViewModels;
76    (function (ViewModels) {
77        var SomeUsagesOfTheseConsts = /** @class */ (function () {
78            function SomeUsagesOfTheseConsts() {
79                // these do get replaced by the const value
80                var value1 = 1 /* ReExportedEnum.Cancel */;
81                console.log(value1);
82                var value2 = 2 /* DialogButtons.OKCancel */;
83                console.log(value2);
84            }
85            return SomeUsagesOfTheseConsts;
86        }());
87        ViewModels.SomeUsagesOfTheseConsts = SomeUsagesOfTheseConsts;
88    })(ViewModels = MsPortalFx.ViewModels || (MsPortalFx.ViewModels = {}));
89})(MsPortalFx || (MsPortalFx = {}));
90
91
92//// [exportImportCanSubstituteConstEnumForValue.d.ts]
93declare module MsPortalFx.ViewModels.Dialogs {
94    const enum DialogResult {
95        Abort = 0,
96        Cancel = 1,
97        Ignore = 2,
98        No = 3,
99        Ok = 4,
100        Retry = 5,
101        Yes = 6
102    }
103    interface DialogResultCallback {
104        (result: MsPortalFx.ViewModels.Dialogs.DialogResult): void;
105    }
106    function someExportedFunction(): void;
107    const enum MessageBoxButtons {
108        AbortRetryIgnore = 0,
109        OK = 1,
110        OKCancel = 2,
111        RetryCancel = 3,
112        YesNo = 4,
113        YesNoCancel = 5
114    }
115}
116declare module MsPortalFx.ViewModels {
117    /**
118     * For some reason javascript code is emitted for this re-exported const enum.
119     */
120    export import ReExportedEnum = Dialogs.DialogResult;
121    /**
122     * Re-exporting a function type to show difference. No javascript is emmitted (as expected)
123     */
124    export import Callback = Dialogs.DialogResultCallback;
125    class SomeUsagesOfTheseConsts {
126        constructor();
127    }
128}
129