mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
44 lines
1.1 KiB
TypeScript
44 lines
1.1 KiB
TypeScript
//// [tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer3.ts] ////
|
|
|
|
//// [assignmentCompatWithStringIndexer3.ts]
|
|
// Derived type indexer must be subtype of base type indexer
|
|
|
|
interface Base { foo: string; }
|
|
interface Derived extends Base { bar: string; }
|
|
interface Derived2 extends Derived { baz: string; }
|
|
|
|
declare var a: A;
|
|
declare var b1: { [x: string]: string; };
|
|
a = b1; // error
|
|
b1 = a; // error
|
|
|
|
namespace Generics {
|
|
class A<T extends Derived> {
|
|
[x: string]: T;
|
|
}
|
|
|
|
function foo<T extends Derived>() {
|
|
var a!: A<T>;
|
|
var b!: { [x: string]: string; };
|
|
a = b; // error
|
|
b = a; // error
|
|
}
|
|
}
|
|
|
|
//// [assignmentCompatWithStringIndexer3.js]
|
|
"use strict";
|
|
// Derived type indexer must be subtype of base type indexer
|
|
a = b1; // error
|
|
b1 = a; // error
|
|
var Generics;
|
|
(function (Generics) {
|
|
class A {
|
|
}
|
|
function foo() {
|
|
var a;
|
|
var b;
|
|
a = b; // error
|
|
b = a; // error
|
|
}
|
|
})(Generics || (Generics = {}));
|