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/anyAssignableToEveryType.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 = a; 41AssertType(b, "number"); 42AssertType(a, "any"); 43 44let c: string = a; 45AssertType(c, "string"); 46AssertType(a, "any"); 47 48let d: boolean = a; 49AssertType(d, "boolean"); 50AssertType(a, "any"); 51 52let e: Date = a; 53AssertType(e, "Date"); 54AssertType(a, "any"); 55 56let f: any = a; 57AssertType(f, "any"); 58AssertType(a, "any"); 59 60let g: void = a; 61AssertType(g, "void"); 62AssertType(a, "any"); 63 64let h: Object = a; 65AssertType(h, "Object"); 66AssertType(a, "any"); 67 68let i: {} = a; 69AssertType(i, "{}"); 70AssertType(a, "any"); 71 72let j: () => {} = a; 73AssertType(j, "() => {}"); 74AssertType(a, "any"); 75 76let k: Function = a; 77AssertType(k, "Function"); 78AssertType(a, "any"); 79 80let l: (x: number) => string = a; 81AssertType(l, "(number) => string"); 82AssertType(x, "number"); 83AssertType(a, "any"); 84 85ac = a; 86AssertType(ac = a, "any"); 87AssertType(ac, "C"); 88AssertType(a, "any"); 89 90ai = a; 91AssertType(ai = a, "any"); 92AssertType(ai, "I"); 93AssertType(a, "any"); 94 95ae = a; 96AssertType(ae = a, "any"); 97AssertType(ae, "E"); 98AssertType(a, "any"); 99 100let m: number[] = a; 101AssertType(m, "number[]"); 102AssertType(a, "any"); 103 104let n: { foo: string } = a; 105AssertType(n, "{ foo: string; }"); 106AssertType(foo, "string"); 107AssertType(a, "any"); 108 109let o: <T>(x: T) => T = a; 110AssertType(o, "<T>(T) => T"); 111AssertType(x, "T"); 112AssertType(a, "any"); 113 114let p: Number = a; 115AssertType(p, "Number"); 116AssertType(a, "any"); 117 118let q: String = a; 119AssertType(q, "String"); 120AssertType(a, "any"); 121 122function foo<T, U /*extends T*/, V extends Date>(x: T, y: U, z: V) { 123 x = a; 124AssertType(x = a, "any"); 125AssertType(x, "T"); 126AssertType(a, "any"); 127 128 y = a; 129AssertType(y = a, "any"); 130AssertType(y, "U"); 131AssertType(a, "any"); 132 133 z = a; 134AssertType(z = a, "any"); 135AssertType(z, "V"); 136AssertType(a, "any"); 137} 138 139//function foo<T, U extends T, V extends Date>(x: T, y: U, z: V) { 140// x = a; 141// y = a; 142// z = a; 143//} 144 145