mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
47 lines
2.1 KiB
Plaintext
47 lines
2.1 KiB
Plaintext
assignmentCompatWithStringIndexer3.ts(7,16): error TS2304: Cannot find name 'A'.
|
|
assignmentCompatWithStringIndexer3.ts(20,9): error TS2322: Type '{ [x: string]: string; }' is not assignable to type 'A<T>'.
|
|
'string' index signatures are incompatible.
|
|
Type 'string' is not assignable to type 'T'.
|
|
'T' could be instantiated with an arbitrary type which could be unrelated to 'string'.
|
|
assignmentCompatWithStringIndexer3.ts(21,9): error TS2322: Type 'A<T>' is not assignable to type '{ [x: string]: string; }'.
|
|
'string' index signatures are incompatible.
|
|
Type 'T' is not assignable to type 'string'.
|
|
Type 'Derived' is not assignable to type 'string'.
|
|
|
|
|
|
==== assignmentCompatWithStringIndexer3.ts (3 errors) ====
|
|
// 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;
|
|
~
|
|
!!! error TS2304: Cannot find name '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
|
|
~
|
|
!!! error TS2322: Type '{ [x: string]: string; }' is not assignable to type 'A<T>'.
|
|
!!! error TS2322: 'string' index signatures are incompatible.
|
|
!!! error TS2322: Type 'string' is not assignable to type 'T'.
|
|
!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'string'.
|
|
b = a; // error
|
|
~
|
|
!!! error TS2322: Type 'A<T>' is not assignable to type '{ [x: string]: string; }'.
|
|
!!! error TS2322: 'string' index signatures are incompatible.
|
|
!!! error TS2322: Type 'T' is not assignable to type 'string'.
|
|
!!! error TS2322: Type 'Derived' is not assignable to type 'string'.
|
|
}
|
|
} |