File: nonPrimitiveUnionIntersection.errors.txt

package info (click to toggle)
node-typescript 4.9.5%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 533,908 kB
  • sloc: javascript: 2,018,330; makefile: 7; sh: 1
file content (26 lines) | stat: -rw-r--r-- 1,637 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
tests/cases/conformance/types/nonPrimitive/nonPrimitiveUnionIntersection.ts(1,5): error TS2322: Type 'string' is not assignable to type 'never'.
tests/cases/conformance/types/nonPrimitive/nonPrimitiveUnionIntersection.ts(3,5): error TS2322: Type 'number' is not assignable to type 'object'.
tests/cases/conformance/types/nonPrimitive/nonPrimitiveUnionIntersection.ts(4,1): error TS2322: Type 'string' is not assignable to type 'never'.
tests/cases/conformance/types/nonPrimitive/nonPrimitiveUnionIntersection.ts(8,38): error TS2322: Type '{ bar: string; }' is not assignable to type 'object & { err: string; }'.
  Object literal may only specify known properties, and 'bar' does not exist in type 'object & { err: string; }'.


==== tests/cases/conformance/types/nonPrimitive/nonPrimitiveUnionIntersection.ts (4 errors) ====
    var a: object & string = ""; // error
        ~
!!! error TS2322: Type 'string' is not assignable to type 'never'.
    var b: object | string = ""; // ok
    var c: object & {} = 123; // error
        ~
!!! error TS2322: Type 'number' is not assignable to type 'object'.
    a = b; // error
    ~
!!! error TS2322: Type 'string' is not assignable to type 'never'.
    b = a; // ok
    
    const foo: object & {} = {bar: 'bar'}; // ok
    const bar: object & {err: string} = {bar: 'bar'}; // error
                                         ~~~~~~~~~~
!!! error TS2322: Type '{ bar: string; }' is not assignable to type 'object & { err: string; }'.
!!! error TS2322:   Object literal may only specify known properties, and 'bar' does not exist in type 'object & { err: string; }'.