28 lines
1.2 KiB
Plaintext
28 lines
1.2 KiB
Plaintext
tests/cases/conformance/types/typeRelationships/typeInference/indexSignatureTypeInference.ts(18,27): error TS2345: Argument of type 'NumberMap<Function>' is not assignable to parameter of type 'StringMap<{}>'.
|
|
Index signature is missing in type 'NumberMap<Function>'.
|
|
|
|
|
|
==== tests/cases/conformance/types/typeRelationships/typeInference/indexSignatureTypeInference.ts (1 errors) ====
|
|
interface NumberMap<T> {
|
|
[index: number]: T;
|
|
}
|
|
|
|
interface StringMap<T> {
|
|
[index: string]: T;
|
|
}
|
|
|
|
declare function numberMapToArray<T>(object: NumberMap<T>): T[];
|
|
declare function stringMapToArray<T>(object: StringMap<T>): T[];
|
|
|
|
var numberMap: NumberMap<Function>;
|
|
var stringMap: StringMap<Function>;
|
|
|
|
var v1: Function[];
|
|
var v1 = numberMapToArray(numberMap); // Ok
|
|
var v1 = numberMapToArray(stringMap); // Ok
|
|
var v1 = stringMapToArray(numberMap); // Error expected here
|
|
~~~~~~~~~
|
|
!!! error TS2345: Argument of type 'NumberMap<Function>' is not assignable to parameter of type 'StringMap<{}>'.
|
|
!!! error TS2345: Index signature is missing in type 'NumberMap<Function>'.
|
|
var v1 = stringMapToArray(stringMap); // Ok
|
|
|