File: excessPropertyCheckWithEmptyObject.errors.txt

package info (click to toggle)
node-typescript 5.0.4%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 459,116 kB
  • sloc: javascript: 1,972,754; makefile: 6; sh: 1
file content (33 lines) | stat: -rw-r--r-- 2,274 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
32
33
tests/cases/compiler/excessPropertyCheckWithEmptyObject.ts(4,58): error TS2345: Argument of type '{ value: string; readonly: boolean; }' is not assignable to parameter of type 'PropertyDescriptor & ThisType<any>'.
  Object literal may only specify known properties, and 'readonly' does not exist in type 'PropertyDescriptor & ThisType<any>'.
tests/cases/compiler/excessPropertyCheckWithEmptyObject.ts(9,30): error TS2322: Type '{ y: number; }' is not assignable to type 'A & ThisType<any>'.
  Object literal may only specify known properties, and 'y' does not exist in type 'A & ThisType<any>'.
tests/cases/compiler/excessPropertyCheckWithEmptyObject.ts(14,34): error TS2322: Type '{ y: string; }' is not assignable to type 'Empty & { x: number; }'.
  Object literal may only specify known properties, and 'y' does not exist in type 'Empty & { x: number; }'.


==== tests/cases/compiler/excessPropertyCheckWithEmptyObject.ts (3 errors) ====
    // Repro from #14910
    
    // Excess property error expected here
    Object.defineProperty(window, "prop", { value: "v1.0.0", readonly: false });
                                                             ~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '{ value: string; readonly: boolean; }' is not assignable to parameter of type 'PropertyDescriptor & ThisType<any>'.
!!! error TS2345:   Object literal may only specify known properties, and 'readonly' does not exist in type 'PropertyDescriptor & ThisType<any>'.
    
    interface A { x?: string }
    
    // Excess property error expected here
    let a: A & ThisType<any> = { y: 10 };
                                 ~~~~~
!!! error TS2322: Type '{ y: number; }' is not assignable to type 'A & ThisType<any>'.
!!! error TS2322:   Object literal may only specify known properties, and 'y' does not exist in type 'A & ThisType<any>'.
    
    interface Empty {}
    
    // Excess property error expected here
    let x: Empty & { x: number } = { y: "hello" };
                                     ~~~~~~~~~~
!!! error TS2322: Type '{ y: string; }' is not assignable to type 'Empty & { x: number; }'.
!!! error TS2322:   Object literal may only specify known properties, and 'y' does not exist in type 'Empty & { x: number; }'.