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