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/everyTypeAssignableToAny.ts === 20declare function AssertType(value:any, type:string):void; 21let a: any; 22AssertType(a, "any"); 23 24class C { 25 foo: string; 26} 27let ac: C; 28AssertType(ac, "C"); 29 30interface I { 31 foo: string; 32} 33let ai: I; 34AssertType(ai, "I"); 35 36enum E { A } 37let ae: E; 38AssertType(ae, "E"); 39 40let b: number; 41AssertType(b, "number"); 42 43let c: string; 44AssertType(c, "string"); 45 46let d: boolean; 47AssertType(d, "boolean"); 48 49let e: Date; 50AssertType(e, "Date"); 51 52let f: any; 53AssertType(f, "any"); 54 55let g: void; 56AssertType(g, "void"); 57 58let h: Object; 59AssertType(h, "Object"); 60 61let i: {}; 62AssertType(i, "{}"); 63 64let j: () => {}; 65AssertType(j, "() => {}"); 66 67let k: Function; 68AssertType(k, "Function"); 69 70let l: (x: number) => string; 71AssertType(l, "(number) => string"); 72AssertType(x, "number"); 73 74let m: number[]; 75AssertType(m, "number[]"); 76 77let n: { foo: string }; 78AssertType(n, "{ foo: string; }"); 79AssertType(foo, "string"); 80 81let o: <T>(x: T) => T; 82AssertType(o, "<T>(T) => T"); 83AssertType(x, "T"); 84 85let p: Number; 86AssertType(p, "Number"); 87 88let q: String; 89AssertType(q, "String"); 90 91a = b; 92AssertType(a = b, "number"); 93AssertType(a, "any"); 94AssertType(b, "number"); 95 96a = c; 97AssertType(a = c, "string"); 98AssertType(a, "any"); 99AssertType(c, "string"); 100 101a = d; 102AssertType(a = d, "boolean"); 103AssertType(a, "any"); 104AssertType(d, "boolean"); 105 106a = e; 107AssertType(a = e, "Date"); 108AssertType(a, "any"); 109AssertType(e, "Date"); 110 111a = f; 112AssertType(a = f, "any"); 113AssertType(a, "any"); 114AssertType(f, "any"); 115 116a = g; 117AssertType(a = g, "void"); 118AssertType(a, "any"); 119AssertType(g, "void"); 120 121a = h; 122AssertType(a = h, "Object"); 123AssertType(a, "any"); 124AssertType(h, "Object"); 125 126a = i; 127AssertType(a = i, "{}"); 128AssertType(a, "any"); 129AssertType(i, "{}"); 130 131a = j; 132AssertType(a = j, "() => {}"); 133AssertType(a, "any"); 134AssertType(j, "() => {}"); 135 136a = k; 137AssertType(a = k, "Function"); 138AssertType(a, "any"); 139AssertType(k, "Function"); 140 141a = l; 142AssertType(a = l, "(number) => string"); 143AssertType(a, "any"); 144AssertType(l, "(number) => string"); 145 146a = m; 147AssertType(a = m, "number[]"); 148AssertType(a, "any"); 149AssertType(m, "number[]"); 150 151a = o; 152AssertType(a = o, "<T>(T) => T"); 153AssertType(a, "any"); 154AssertType(o, "<T>(T) => T"); 155 156a = p; 157AssertType(a = p, "Number"); 158AssertType(a, "any"); 159AssertType(p, "Number"); 160 161a = q; 162AssertType(a = q, "String"); 163AssertType(a, "any"); 164AssertType(q, "String"); 165 166a = ac; 167AssertType(a = ac, "C"); 168AssertType(a, "any"); 169AssertType(ac, "C"); 170 171a = ai; 172AssertType(a = ai, "I"); 173AssertType(a, "any"); 174AssertType(ai, "I"); 175 176a = ae; 177AssertType(a = ae, "E"); 178AssertType(a, "any"); 179AssertType(ae, "E"); 180 181function foo<T, U /*extends T*/, V extends Date>(x: T, y: U, z: V) { 182 a = x; 183AssertType(a = x, "T"); 184AssertType(a, "any"); 185AssertType(x, "T"); 186 187 a = y; 188AssertType(a = y, "U"); 189AssertType(a, "any"); 190AssertType(y, "U"); 191 192 a = z; 193AssertType(a = z, "V"); 194AssertType(a, "any"); 195AssertType(z, "V"); 196} 197//function foo<T, U extends T, V extends Date>(x: T, y: U, z: V) { 198// a = x; 199// a = y; 200// a = z; 201//} 202 203