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