1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
|
=== tests/cases/compiler/implicitAnyCastedValue.ts ===
var x = function () {
>x : () => any
>function () { return <any>0; // this should not be an error} : () => any
return <any>0; // this should not be an error
><any>0 : any
>0 : 0
}
function foo() {
>foo : () => any
return <any>"hello world"; // this should not be an error
><any>"hello world" : any
>"hello world" : "hello world"
}
class C {
>C : C
bar = null; // this should be an error
>bar : any
>null : null
foo = undefined; // this should be an error
>foo : any
>undefined : undefined
public get tempVar() {
>tempVar : any
return <any>0; // this should not be an error
><any>0 : any
>0 : 0
}
public returnBarWithCase() { // this should not be an error
>returnBarWithCase : () => any
return <any>this.bar;
><any>this.bar : any
>this.bar : any
>this : this
>bar : any
}
public returnFooWithCase() {
>returnFooWithCase : () => any
return <any>this.foo; // this should not be an error
><any>this.foo : any
>this.foo : any
>this : this
>foo : any
}
}
class C1 {
>C1 : C1
getValue = null; // this should be an error
>getValue : any
>null : null
public get castedGet() {
>castedGet : any
return <any>this.getValue; // this should not be an error
><any>this.getValue : any
>this.getValue : any
>this : this
>getValue : any
}
public get notCastedGet() {
>notCastedGet : any
return this.getValue; // this should not be an error
>this.getValue : any
>this : this
>getValue : any
}
}
function castedNull() {
>castedNull : () => any
return <any>null; // this should not be an error
><any>null : any
>null : null
}
function notCastedNull() {
>notCastedNull : () => any
return null; // this should be an error
>null : null
}
function returnTypeBar(): any {
>returnTypeBar : () => any
return null; // this should not be an error
>null : null
}
function undefinedBar() {
>undefinedBar : () => any
return <any>undefined; // this should not be an error
><any>undefined : any
>undefined : undefined
}
function multipleRets1(x) { // this should not be an error
>multipleRets1 : (x: any) => any
>x : any
if (x) {
>x : any
return <any>0;
><any>0 : any
>0 : 0
}
else {
return null;
>null : null
}
}
function multipleRets2(x) { // this should not be an error
>multipleRets2 : (x: any) => any
>x : any
if (x) {
>x : any
return null;
>null : null
}
else if (x == 1) {
>x == 1 : boolean
>x : any
>1 : 1
return <any>0;
><any>0 : any
>0 : 0
}
else {
return undefined;
>undefined : undefined
}
}
// this should not be an error
var bar1 = <any>null;
>bar1 : any
><any>null : any
>null : null
var bar2 = <any>undefined;
>bar2 : any
><any>undefined : any
>undefined : undefined
var bar3 = <any>0;
>bar3 : any
><any>0 : any
>0 : 0
var array = <any>[null, undefined];
>array : any
><any>[null, undefined] : any
>[null, undefined] : null[]
>null : null
>undefined : undefined
|