TypeScript/tests/baselines/reference/assignmentCompat1.js
Nathan Shively-Sanders 5cd0ca19af Add test case, correct existing test case
Existing: String assignment to a numeric indexer should succeed, not fail.
  (The baseline was already correct but the inline comment was wrong.)
New: Boolean assignment to a numeric indexer should fail.
2015-10-15 11:04:36 -07:00

26 lines
627 B
TypeScript

//// [assignmentCompat1.ts]
var x = { one: 1 };
var y: { [index: string]: any };
var z: { [index: number]: any };
x = y; // Error
y = x; // Ok because index signature type is any
x = z; // Error
z = x; // Ok because index signature type is any
y = "foo"; // Error
z = "foo"; // OK, string has numeric indexer
z = false; // Error
//// [assignmentCompat1.js]
var x = { one: 1 };
var y;
var z;
x = y; // Error
y = x; // Ok because index signature type is any
x = z; // Error
z = x; // Ok because index signature type is any
y = "foo"; // Error
z = "foo"; // OK, string has numeric indexer
z = false; // Error