52 lines
1.1 KiB
Text
52 lines
1.1 KiB
Text
|
=== tests/cases/compiler/assignmentCompat1.ts ===
|
||
|
var x = { one: 1 };
|
||
|
>x : { one: number; }
|
||
|
>{ one: 1 } : { one: number; }
|
||
|
>one : number
|
||
|
>1 : 1
|
||
|
|
||
|
var y: { [index: string]: any };
|
||
|
>y : { [index: string]: any; }
|
||
|
>index : string
|
||
|
|
||
|
var z: { [index: number]: any };
|
||
|
>z : { [index: number]: any; }
|
||
|
>index : number
|
||
|
|
||
|
x = y; // Error
|
||
|
>x = y : { [index: string]: any; }
|
||
|
>x : { one: number; }
|
||
|
>y : { [index: string]: any; }
|
||
|
|
||
|
y = x; // Ok because index signature type is any
|
||
|
>y = x : { one: number; }
|
||
|
>y : { [index: string]: any; }
|
||
|
>x : { one: number; }
|
||
|
|
||
|
x = z; // Error
|
||
|
>x = z : { [index: number]: any; }
|
||
|
>x : { one: number; }
|
||
|
>z : { [index: number]: any; }
|
||
|
|
||
|
z = x; // Ok because index signature type is any
|
||
|
>z = x : { one: number; }
|
||
|
>z : { [index: number]: any; }
|
||
|
>x : { one: number; }
|
||
|
|
||
|
y = "foo"; // Error
|
||
|
>y = "foo" : "foo"
|
||
|
>y : { [index: string]: any; }
|
||
|
>"foo" : "foo"
|
||
|
|
||
|
z = "foo"; // OK, string has numeric indexer
|
||
|
>z = "foo" : "foo"
|
||
|
>z : { [index: number]: any; }
|
||
|
>"foo" : "foo"
|
||
|
|
||
|
z = false; // Error
|
||
|
>z = false : false
|
||
|
>z : { [index: number]: any; }
|
||
|
>false : false
|
||
|
|
||
|
|