File: excessPropertyCheckIntersectionWithIndexSignature.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 (29 lines) | stat: -rw-r--r-- 1,611 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
29
tests/cases/compiler/excessPropertyCheckIntersectionWithIndexSignature.ts(5,7): error TS2322: Type '{ a: 0; }' is not assignable to type '{ a: 0; } & { b: 0; }'.
  Property 'b' is missing in type '{ a: 0; }' but required in type '{ b: 0; }'.
tests/cases/compiler/excessPropertyCheckIntersectionWithIndexSignature.ts(7,24): error TS2322: Type '{ a: 0; b: 0; c: number; }' is not assignable to type '{ a: 0; } & { b: 0; }'.
  Object literal may only specify known properties, and 'c' does not exist in type '{ a: 0; } & { b: 0; }'.


==== tests/cases/compiler/excessPropertyCheckIntersectionWithIndexSignature.ts (2 errors) ====
    // Repro from #51875
    
    let x: { [x: string]: { a: 0 } } & { [x: string]: { b: 0 } };
    
    x = { y: { a: 0 } };  // Error
          ~
!!! error TS2322: Type '{ a: 0; }' is not assignable to type '{ a: 0; } & { b: 0; }'.
!!! error TS2322:   Property 'b' is missing in type '{ a: 0; }' but required in type '{ b: 0; }'.
!!! related TS2728 tests/cases/compiler/excessPropertyCheckIntersectionWithIndexSignature.ts:3:53: 'b' is declared here.
    x = { y: { a: 0, b: 0 } };
    x = { y: { a: 0, b: 0, c: 0 } };  // Error
                           ~~~~
!!! error TS2322: Type '{ a: 0; b: 0; c: number; }' is not assignable to type '{ a: 0; } & { b: 0; }'.
!!! error TS2322:   Object literal may only specify known properties, and 'c' does not exist in type '{ a: 0; } & { b: 0; }'.
    
    type A = { a: string };
    type B = { b: string };
    
    const yy: Record<string, A> & Record<string, B> = {
        foo: { a: '', b: '' },
    };