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/conformance/expressions/binaryOperators/instanceofOperator/instanceofOperatorWithLHSIsObject.ts === 20declare function AssertType(value:any, type:string):void; 21class C { } 22 23let x1: any; 24AssertType(x1, "any"); 25 26let x2: Function; 27AssertType(x2, "Function"); 28 29let a: {}; 30AssertType(a, "{}"); 31 32let b: Object; 33AssertType(b, "Object"); 34 35let c: C; 36AssertType(c, "C"); 37 38let d: string | C; 39AssertType(d, "union"); 40 41let r1 = a instanceof x1; 42AssertType(r1, "boolean"); 43AssertType(a instanceof x1, "boolean"); 44AssertType(a, "{}"); 45AssertType(x1, "any"); 46 47let r2 = b instanceof x2; 48AssertType(r2, "boolean"); 49AssertType(b instanceof x2, "boolean"); 50AssertType(b, "Object"); 51AssertType(x2, "Function"); 52 53let r3 = c instanceof x1; 54AssertType(r3, "boolean"); 55AssertType(c instanceof x1, "boolean"); 56AssertType(c, "C"); 57AssertType(x1, "any"); 58 59let r4 = d instanceof x1; 60AssertType(r4, "boolean"); 61AssertType(d instanceof x1, "boolean"); 62AssertType(d, "union"); 63AssertType(x1, "any"); 64 65 66