File: nonPrimitiveUnionIntersection.errors.txt

package info (click to toggle)
node-typescript 4.1.3-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 396,552 kB
  • sloc: javascript: 1,444,377; makefile: 7; sh: 3
file content (28 lines) | stat: -rw-r--r-- 1,771 bytes parent folder | download
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
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 & {}'.
  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 & {}'.
!!! 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; }'.