mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
27 lines
699 B
TypeScript
27 lines
699 B
TypeScript
//// [tests/cases/compiler/assignmentCompat1.ts] ////
|
|
|
|
//// [assignmentCompat1.ts]
|
|
var x = { one: 1 };
|
|
declare var y: { [index: string]: any };
|
|
declare 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]
|
|
"use strict";
|
|
var x = { one: 1 };
|
|
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
|