1/* 2* Copyright (c) Microsoft Corporation. All rights reserved. 3* Copyright (c) 2023 Huawei Device Co., Ltd. 4* Licensed under the Apache License, Version 2.0 (the "License"); 5* you may not use this file except in compliance with the License. 6* You may obtain a copy of the License at 7* 8* http://www.apache.org/licenses/LICENSE-2.0 9* 10* Unless required by applicable law or agreed to in writing, software 11* distributed under the License is distributed on an "AS IS" BASIS, 12* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13* See the License for the specific language governing permissions and 14* limitations under the License. 15* 16* This file has been modified by Huawei to verify type inference by adding verification statements. 17*/ 18 19// === tests/cases/compiler/exportImportCanSubstituteConstEnumForValue.ts === 20declare function AssertType(value:any, type:string):void; 21module MsPortalFx.ViewModels.Dialogs { 22 23 export const enum DialogResult { 24 Abort, 25 Cancel, 26 Ignore, 27 No, 28 Ok, 29 Retry, 30 Yes, 31 } 32 33 export interface DialogResultCallback { 34 (result: MsPortalFx.ViewModels.Dialogs.DialogResult): void; 35 } 36 37 export function someExportedFunction() { 38 } 39 40 export const enum MessageBoxButtons { 41 AbortRetryIgnore, 42 OK, 43 OKCancel, 44 RetryCancel, 45 YesNo, 46 YesNoCancel, 47 } 48} 49 50 51module MsPortalFx.ViewModels { 52 53 /** 54 * For some reason javascript code is emitted for this re-exported const enum. 55 */ 56 export import ReExportedEnum = Dialogs.DialogResult; 57 58 /** 59 * Not exported to show difference. No javascript is emmitted (as expected) 60 */ 61 import DialogButtons = Dialogs.MessageBoxButtons; 62 63 /** 64 * Re-exporting a function type to show difference. No javascript is emmitted (as expected) 65 */ 66 export import Callback = Dialogs.DialogResultCallback; 67 68 export class SomeUsagesOfTheseConsts { 69 constructor() { 70 // these do get replaced by the const value 71 const value1 = ReExportedEnum.Cancel; 72AssertType(value1, "ReExportedEnum.Cancel"); 73AssertType(ReExportedEnum.Cancel, "ReExportedEnum.Cancel"); 74 75 console.log(value1); 76AssertType(console.log(value1), "void"); 77AssertType(console.log, "(...any[]) => void"); 78AssertType(value1, "ReExportedEnum.Cancel"); 79 80 const value2 = DialogButtons.OKCancel; 81AssertType(value2, "DialogButtons.OKCancel"); 82AssertType(DialogButtons.OKCancel, "DialogButtons.OKCancel"); 83 84 console.log(value2); 85AssertType(console.log(value2), "void"); 86AssertType(console.log, "(...any[]) => void"); 87AssertType(value2, "DialogButtons.OKCancel"); 88 } 89 } 90} 91 92 93