File: indexSignatureTypeInference.errors.txt

package info (click to toggle)
node-typescript 5.0.4%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 459,140 kB
  • sloc: javascript: 1,972,754; makefile: 6; sh: 1
file content (32 lines) | stat: -rw-r--r-- 1,857 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
tests/cases/conformance/types/typeRelationships/typeInference/indexSignatureTypeInference.ts(18,5): error TS2403: Subsequent variable declarations must have the same type.  Variable 'v1' must be of type 'Function[]', but here has type 'unknown[]'.
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<unknown>'.
  Index signature for type 'string' is missing in type 'NumberMap<Function>'.


==== tests/cases/conformance/types/typeRelationships/typeInference/indexSignatureTypeInference.ts (2 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 TS2403: Subsequent variable declarations must have the same type.  Variable 'v1' must be of type 'Function[]', but here has type 'unknown[]'.
!!! related TS6203 tests/cases/conformance/types/typeRelationships/typeInference/indexSignatureTypeInference.ts:15:5: 'v1' was also declared here.
                              ~~~~~~~~~
!!! error TS2345: Argument of type 'NumberMap<Function>' is not assignable to parameter of type 'StringMap<unknown>'.
!!! error TS2345:   Index signature for type 'string' is missing in type 'NumberMap<Function>'.
    var v1 = stringMapToArray(stringMap);  // Ok