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/types/typeRelationships/assignmentCompatibility/anyAssignableToEveryType2.ts === 20declare function AssertType(value:any, type:string):void; 21 22// any is not a subtype of any other types, but is assignable, all the below should work 23 24interface I { 25 [x: string]: any; 26 foo: any; // ok, any identical to itself 27} 28 29 30interface I2 { 31 [x: string]: number; 32 foo: any; 33} 34 35 36interface I3 { 37 [x: string]: string; 38 foo: any; 39} 40 41 42interface I4 { 43 [x: string]: boolean; 44 foo: any; 45} 46 47 48interface I5 { 49 [x: string]: Date; 50 foo: any; 51} 52 53 54interface I6 { 55 [x: string]: RegExp; 56 foo: any; 57} 58 59 60interface I7 { 61 [x: string]: { bar: number }; 62 foo: any; 63} 64 65 66interface I8 { 67 [x: string]: number[]; 68 foo: any; 69} 70 71 72interface I9 { 73 [x: string]: I8; 74 foo: any; 75} 76 77class A { foo: number; } 78interface I10 { 79 [x: string]: A; 80 foo: any; 81} 82 83class A2<T> { foo: T; } 84interface I11 { 85 [x: string]: A2<number>; 86 foo: any; 87} 88 89 90interface I12 { 91 [x: string]: (x) => number; 92 foo: any; 93} 94 95 96interface I13 { 97 [x: string]: <T>(x: T) => T; 98 foo: any; 99} 100 101 102enum E { A } 103interface I14 { 104 [x: string]: E; 105 foo: any; 106} 107 108 109function f() { } 110module f { 111 export let bar = 1; 112} 113interface I15 { 114 [x: string]: typeof f; 115 foo: any; 116} 117 118 119class c { baz: string } 120module c { 121 export let bar = 1; 122} 123interface I16 { 124 [x: string]: typeof c; 125 foo: any; 126} 127 128 129interface I17<T> { 130 [x: string]: T; 131 foo: any; 132} 133 134 135interface I18<T, U extends T> { 136 [x: string]: U; 137 foo: any; 138} 139 140 141interface I19 { 142 [x: string]: Object; 143 foo: any; 144} 145 146 147interface I20 { 148 [x: string]: {}; 149 foo: any; 150} 151 152 153