File: nonPrimitiveInFunction.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 (31 lines) | stat: -rw-r--r-- 1,301 bytes parent folder | download | duplicates (5)
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
tests/cases/conformance/types/nonPrimitive/nonPrimitiveInFunction.ts(12,12): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'object'.
tests/cases/conformance/types/nonPrimitive/nonPrimitiveInFunction.ts(13,1): error TS2322: Type 'object' is not assignable to type 'boolean'.
tests/cases/conformance/types/nonPrimitive/nonPrimitiveInFunction.ts(17,5): error TS2322: Type 'number' is not assignable to type 'object'.


==== tests/cases/conformance/types/nonPrimitive/nonPrimitiveInFunction.ts (3 errors) ====
    function takeObject(o: object) {}
    function returnObject(): object {
        return {};
    }
    
    var nonPrimitive: object;
    var primitive: boolean;
    
    takeObject(nonPrimitive);
    nonPrimitive = returnObject();
    
    takeObject(primitive); // expect error
               ~~~~~~~~~
!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'object'.
    primitive = returnObject(); // expect error
    ~~~~~~~~~
!!! error TS2322: Type 'object' is not assignable to type 'boolean'.
    
    function returnError(): object {
        var ret = 123;
        return ret; // expect error
        ~~~~~~~~~~~
!!! error TS2322: Type 'number' is not assignable to type 'object'.
    }