File: typeFromPropertyAssignment28.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 (23 lines) | stat: -rw-r--r-- 1,072 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
tests/cases/conformance/salsa/a.js(7,17): error TS2322: Type '{ q: number; }' is not assignable to type 'C'.
  Object literal may only specify known properties, and 'q' does not exist in type 'C'.
tests/cases/conformance/salsa/a.js(11,3): error TS2339: Property 'q' does not exist on type 'C'.


==== tests/cases/conformance/salsa/a.js (2 errors) ====
    // mixed prototype-assignment+class declaration
    class C { constructor() { this.p = 1; } }
    // Property assignment does nothing.
    // You have to use Object.defineProperty(C, "prototype", { q: 2 })
    // and that only works on classes with no superclass.
    // (Object.defineProperty isn't recognised as a JS special assignment right now.)
    C.prototype = { q: 2 };
                    ~~~~
!!! error TS2322: Type '{ q: number; }' is not assignable to type 'C'.
!!! error TS2322:   Object literal may only specify known properties, and 'q' does not exist in type 'C'.
    
    const c = new C()
    c.p
    c.q
      ~
!!! error TS2339: Property 'q' does not exist on type 'C'.